我正在尝试制作一个小部件,它是一个切换按钮,就像 android 控件小部件中的那些(wlan、蓝牙等的快速设置)。
Here's how it looks (@控件小部件)
有谁知道这个布局是否包含在 android sdk 中,如果没有,我该如何制作一个像那个布局一样的布局?
我已经尝试了一些东西,但我不知道如何处理底部的笔画。
最佳答案
关于您的问题,我进行了更深入的搜索。
参见:https://developer.android.com/guide/topics/appwidgets/index.html
这些是您可以与 appwidget 一起使用以在您的布局中实现的类,没有像切换按钮这样的东西,而是一个图像按钮,我认为我们正是谷歌正在使用的“切换按钮”。仔细看看 imagebutton : https://developer.android.com/reference/android/widget/ImageButton.html
然后你会发现这正是你要找的。p>
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.
我无法想象仅使用干净的 xml 就可以实现如此复杂的布局...
希望现在对您有所帮助!
关于Android控件widget布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27066937/