Android control widget layout

467 Views Asked by At

I'm trying to make a widget which is a togglebutton like the ones in the android control widget (the quicksettings for wlan, bluetooth etc.).

Here's how it looks (@Control Widgets)

Does anyone know if this layout is contained in the android sdk or if not how I can make a layout just like that one?

I've already tried some things but I don't know how do to the stroke at the bottom.

1

There are 1 best solutions below

2
On BEST ANSWER

Regarding to your issue I searched a little bit deeper.

See: https://developer.android.com/guide/topics/appwidgets/index.html

These are the classes which you can use with an appwidget to implement in your layout there is no such thing like a toggle button, but an imagebutton which I think us exactly what Google is using for the "toggle buttons". Take a closer look on the imagebutton : https://developer.android.com/reference/android/widget/ImageButton.html

Then you will find out it's exactly what you are looking for.

    By default, an ImageButton looks like a regularButton, with the standard button background that changes color during different button states. The image on the surface of the button is defined either by the android:src attribute in the XML element or by thesetImageResource(int) method.

I can't imagine that such a complex layout is possible just using clean xml...

Hope it helps now!