我想在Android中创建一个简单的布局。基本上我的大矩形应该是水平和垂直居中。小按钮垂直定位在屏幕底部和屏幕中心之间等距离并水平居中。 在Android中使用LinearLayout设置两个对象
大矩形的外形尺寸是354×168 小矩形的外形尺寸是124x48
我应该使用线性布局或相对布局?我将不胜感激任何帮助。
我想在Android中创建一个简单的布局。基本上我的大矩形应该是水平和垂直居中。小按钮垂直定位在屏幕底部和屏幕中心之间等距离并水平居中。 在Android中使用LinearLayout设置两个对象
大矩形的外形尺寸是354×168 小矩形的外形尺寸是124x48
我应该使用线性布局或相对布局?我将不胜感激任何帮助。
试试这个:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/button1"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:background="#000" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/button1" >
<Button
android:id="@+id/button2"
android:layout_width="60dp"
android:layout_height="20dp"
android:layout_centerInParent="true"
android:background="#000" />
</RelativeLayout>
</RelativeLayout>
让我们了解您到目前为止试过。 – Squonk