我在線性佈局中有一個按鈕。我希望按鈕佔用其父項寬度的一半。有沒有辦法在佈局xml中做到這一點。屏幕的按鈕半寬度
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:padding="6dp">
<Button
android:id="@+id/buttonCollect"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/hello"
android:paddingLeft="8dp"
android:paddingRight="8dp"/>
</LinearLayout>
我的問題是很多像這樣的Assign width to half available screen width declaratively除了我只有一個按鈕。
可能重複[分配寬聲明一半可用屏幕寬度(http://stackoverflow.com/questions/ 2581481/assign-width-to-half-available-screen-width-declaratively) – Saif 2014-12-14 06:34:08