1

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:

app layout

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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
BobMcboberson
  • 2,065
  • 2
  • 13
  • 13
  • 1
    Tried your code snippet and there was no problem with distortion. Is the problem still there if you try with another APK version in the emulator? – HenrikS Jul 05 '11 at 15:25
  • Yes it is. Tommorow I'll try it on my bosses Nexus S. But I appreciate you trying my code. Thanks mate. – BobMcboberson Jul 05 '11 at 21:09

0 Answers0