这可以通过在布局上放置两个小部件来完成:

使用LinearLayout并在两个小部件(Button和另一个小部件)上设置layout_width =“fill_parent”,并将layout_weight也设置为相同的值.

并且LinearLayout将平均分割两个小部件之间的宽度,您的按钮将占据屏幕的一半.

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="horizontal">

android:id="@+id/buttonCollect"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:paddingLeft="8dp"

android:paddingRight="8dp"

android:text="przycisk" />

android:id="@+id/button2"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:layout_alignParentBottom="true"

android:layout_alignParentRight="true"

android:text="Button" />

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐