android设置按钮长度,Android设置按钮宽度为屏幕的一半
这可以通过在布局上放置两个小部件来完成:使用LinearLayout并在两个小部件(Button和另一个小部件)上设置layout_width =“fill_parent”,并将layout_weight也设置为相同的值.并且LinearLayout将平均分割两个小部件之间的宽度,您的按钮将占据屏幕的一半.xmlns:tools="http://schemas.android.com/tools"
这可以通过在布局上放置两个小部件来完成:
使用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" />
更多推荐



所有评论(0)