简体   繁体   English

Android控件小部件布局

[英]Android control widget layout

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.). 我正在尝试制作一个小部件,它是一个类似于android控件小部件(WLAN,蓝牙等的快速设置)中的切换按钮。

Here's how it looks (@Control Widgets) 这是它的外观 (@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? 有谁知道这个布局是否包含在android sdk中,或者如果不可以,我该如何制作一个布局呢?

I've already tried some things but I don't know how do to the stroke at the bottom. 我已经尝试过一些方法,但是我不知道如何对底部的笔触进行处理。

Regarding to your issue I searched a little bit deeper. 关于您的问题,我进行了更深入的搜索。

See: https://developer.android.com/guide/topics/appwidgets/index.html 请参阅: 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". 这些是可以与appwidget一起使用以在布局中实现的类,没有像切换按钮之类的东西,但是有一个imagebutton,我认为我们正是Google用于“切换按钮”的东西。 Take a closer look on the imagebutton : https://developer.android.com/reference/android/widget/ImageButton.html 仔细看一下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... 我无法想象仅使用干净的xml就可以实现如此复杂的布局...

Hope it helps now! 希望现在对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM