我想在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