如何在XML中设置按钮宽度为屏幕的一半?我只找到了wrap content(内容自适应大小)、match parent(填充整个屏幕)和确切的dp值,比如50dp。如何让它精确地占据一半屏幕的宽度?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
>
<Button
android:id="@+id/buttonCollect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="przycisk" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Button" />