开发者

Removing Android ToggleButton's green indicator light

开发者 https://www.devze.com 2023-02-22 10:03 出处:网络
I would like my app to have a day of week selector with multiple day selection capabili开发者_JAVA百科ty. I\'m using ToggleButtons for this right now, but because of the indicator lights a ToggleButto

I would like my app to have a day of week selector with multiple day selection capabili开发者_JAVA百科ty. 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?


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" />


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消