Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing Android ToggleButton's green indicator light

I would like my app to have a day of week selector with multiple day selection capability. I'm using ToggleButtons for this right now, but because of the indicator lights a ToggleButton takes too much space on the screen. Without the lights, my ToggleButtons would look like normal (toggleable) Buttons and they could fit in one row. How can I hide the lights?

like image 867
Nonoo Avatar asked Apr 04 '11 11:04

Nonoo


2 Answers

The answer is this part:

android:background="@android:drawable/btn_default"

For example, following will make the light disappear and toggle button would look like a default button, but with the toggle functionality:

    <ToggleButton android:id="@+id/your_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textOn="On" android:textOff="Off"
android:background="@android:drawable/btn_default" />
like image 198
Turtletrail Avatar answered Sep 21 '22 02:09

Turtletrail


You can use a custom android:background drawable for them, that will override the graphics including the indicator light. If you look at Android: using framework drawables in custom button selector, there's instructions for copying resources from the SDK to your own project. You presumably could copy the platform normal button drawable and use that as your background.

like image 42
Ilkka Avatar answered Sep 24 '22 02:09

Ilkka