Android鎬庝箞璋冩暣鎸夐挳浣嶇疆
瑕佽皟鏁存寜閽綅缃紝鎮ㄥ彲浠ュ湪甯冨眬鏂囦欢涓娇鐢ㄥ竷灞€灞炴€ф潵鎺у埗鎸夐挳鐨勪綅缃€備互涓嬫槸涓€浜涘父鐢ㄧ殑甯冨眬灞炴€у拰绀轰緥浠g爜锛?/p>
- 浣跨敤android:layout_gravity灞炴€ц皟鏁存寜閽湪鐖跺竷灞€涓殑浣嶇疆锛屽彲浠ヨ缃负"left"銆佲€渞ight鈥濄€佲€渢op鈥濄€?quot;bottom"绛夈€?/li>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_gravity="center_horizontal" />
- 浣跨敤android:layout_margin灞炴€ц缃寜閽笌鍛ㄥ洿鍏冪礌涔嬮棿鐨勯棿璺濄€?/li>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp" />
- 浣跨敤android:layout_alignParent灞炴€у皢鎸夐挳鐩稿浜庣埗甯冨眬杩涜瀹氫綅銆?/li>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
- 浣跨敤RelativeLayout甯冨眬鏉ュ疄鐜板鏉傜殑鎸夐挳浣嶇疆璋冩暣銆?/li>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"
android:layout_below="@id/button1"
android:layout_alignStart="@id/button1" />
</RelativeLayout>
閫氳繃浠ヤ笂鏂规硶锛屾偍鍙互杞绘澗鍦拌皟鏁存寜閽殑浣嶇疆锛屽疄鐜版偍鎯宠鐨勫竷灞€鏁堟灉銆?/p>
相关问答