layout_weight內的佈局不起作用layout_weight不起作用,在設計視圖中顯示正確,但編譯時出錯並停止編譯 我的代碼是當相對佈局中的Linearlayout(只有問題出現在layout_weight中)時,相對佈局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/black"
android:id="@+id/ll_bookmarkslistad"
android:weightSum="100"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="30" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="70"
android:layout_marginRight="0.0dp" />
</LinearLayout>
</RelativeLayout>
歡迎來到堆棧溢出!爲了幫助人們回答您的問題,您需要更加具體地瞭解錯誤。請[編輯]您的帖子以合併您從[mcve]中獲得的確切錯誤(最好使用複製+粘貼以避免轉錄錯誤)。 –
第一件事,在你的xml中你沒有添加線性佈局的方向,第二件事是你已經添加了線寬佈局的權重,那麼你必須將子視圖的高度或寬度設置爲0dp以及所需的重量對於視圖(你已經在你的xml中指定了它)。現在我的問題是你想實現什麼?你想要在屏幕中心的兩個按鈕? –
和我的建議是,而不是使用填充家長使用匹配的父母,因爲他們都做同樣的工作,並填寫家長在棄用, –