Android控件widget布局

标签 android android-layout android-widget

我正在尝试制作一个小部件,它是一个切换按钮,就像 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

然后你会发现这正是你要找的。

    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/

相关文章:

android - Arc 菜单项样式类似于 Android 的 tumblr 应用程序

android - 如何在位图或绘图中添加文本?

android - 如何在不使用任何库的情况下检测android中的IBeacon

java - Android 设备上的 IndexOutOfBoundsException 错误不在模拟器上

java - 使 android-textview 的某个部分向右对齐

android - 获取 GridView 项目的图像名称

android - 按钮中间的进度条

android - 为什么在 Android 中只有部分背景颜色发生变化?

android - styles.xml 中未解析的几个 android 属性

android - 使用库更新应用程序后小部件消失