1. 程式人生 > >android開發兩個按鈕各佔螢幕一半擺放的方法

android開發兩個按鈕各佔螢幕一半擺放的方法

兩個或多個按鈕水平一起擺放, 讓這兩個或多個按鈕平均的放置,可以讓介面看起來跟好看舒服。

下面是兩個按鈕各佔螢幕一半擺放的方法,多個按鈕的擺放類似:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
 
    <Button
        android:id="@+id/scan_button"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Scan..." />
 
    <Button
        android:id="@+id/con_button"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Connect" />
 
</LinearLayout>