Android Toggle Button distorted view

最后都变了- 提交于 2019-12-11 05:39:33

问题


I am building a app. At the moment I am just building a test UI so I can show off the functionality of the app. I ran across a problem where I want to have three ToggleButtons displayed in a horizontal fashion. So I did this using a Linear view. How ever the buttons are distorted looking. Here is a picture of the distortion:

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

Called in onCreate()

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

Layout 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>

Note: - I tried removing a button for the linear view and replacing it instead below the close button. - I tried placing it in a RelativeLayout instead of LinearLayout. - Playing with the width and height of the layout/buttons.

来源:https://stackoverflow.com/questions/6583531/android-toggle-button-distorted-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!