1

アプリを作成しています。現時点では、アプリの機能を披露できるように、テストUIを作成しています。3つのToggleButtonを水平に表示したいという問題に遭遇しました。だから私は線形ビューを使用してこれを行いました。ただし、ボタンの見た目が歪んでいます。これが歪みの写真です:

アプリのレイアウト

private ToggleButton wifiTB;
private ToggleButton gpsTB;
private ToggleButton bluetoothTB;

onCreate()で呼び出されます

wifiTB = (ToggleButton)this.findViewById(R.id.WifiTB);
gpsTB = (ToggleButton)this.findViewById(R.id.GPSTB);
bluetoothTB = (ToggleButton)this.findViewById(R.id.bluetoothTB);

レイアウトxml:

<LinearLayout android:id="@+id/linearLayout1"
    android:layout_height="wrap_content" android:layout_width="match_parent"
    android:gravity="center">
    <ToggleButton android:id="@+id/WifiTB" android:textOn="Wifi"
        android:textOff="Wifi" android:layout_weight="1"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></ToggleButton>
    <ToggleButton android:layout_width="wrap_content"
        android:id="@+id/GPSTB" android:textOn="GPS" android:textOff="GPS"
        android:layout_weight="1" android:layout_height="wrap_content"></ToggleButton>
    <ToggleButton android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:id="@+id/bluetoothTB"
        android:textOn="Bluetooth" android:textOff="Bluetooth"
        android:layout_weight="1"></ToggleButton>
</LinearLayout>

注:-線形ビューのボタンを削除して、代わりに閉じるボタンの下に置き換えてみました。--LinearLayoutではなくRelativeLayoutに配置してみました。-レイアウト/ボタンの幅と高さで遊んでください。

4

0 に答える 0