我在线性布局中有一个按钮。我希望按钮占用其父项宽度的一半。有没有办法在布局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