Android:使用 AppWidget 及其允许的操作
我来这里是为了解决我对AppWidget的疑问。 目前我正在尝试构建一个可视化时间表的AppWidget; 我构建了一个布局,其中包含一周中的几天的列,其中包含: 一个 FrameLayout,其中包含一个 LinearLayout(用于背景)和一个要在其中放置用户约会的相对布局。 关于约会,我想构建 TextView,它在相对布局中的尺寸、颜色和位置可以不同......
有谁知道如何做到这一点吗?
我发现 RemoteView 的可用操作非常有限,但同时我发现了一些具有此功能的 AppWidget。
非常感谢。
I'm here to ask you an help to my doubts on AppWidget.
At the moment I'm trying to build an AppWidget that visualizes a timetable;
I have build a layout that contains columns for days of week made of:
a FrameLayout that contains a LinearLayout(for a background) and a RelativeLayout in which I want to put user appointments.
About appointments I want to build TextView that can be different in dimension, color, and position in the RelativeLayout...
is there anyone who knows how to this?
I have seen that RemoteViews are very limited in available actions but at the same time I have found some AppWidgets those do this feature..
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在一定程度上操作小部件(例如,在更新小部件时设置完全不同的小部件布局),但是,
RemoteViews
是有一定限制的。由于你的问题的第一部分很模糊,我只能在这里给出这个答案。但是您可以使用哪些View
以及在RemoteView
上可以进行哪些操作都有很好的文档记录。您可能已经看到并且很常见的是看起来像小部件但实际上是启动器功能的东西。例如 HTC sense 小部件。对于菜单、列表视图和其他一些东西中的一个小部件条目,它们可以具有不同的大小。那是因为他们以一种未记录的方式使用感知启动器,外部开发人员无法使用。通常,您可以通过使用不同的启动器(例如 android stock 启动器)放置有问题的小部件来确定该小部件是否是真正的小部件。这些“特殊”小部件无法完成此操作,它们会显示错误。
You can manipulate widgets to a certain extend (e.g. setting a completely different widget layout when updating it), but yes,
RemoteViews
are somewhat limited. Since the first part of your question is vague, I can only give this answer here. But whichViews
you can use and what operations are available onRemoteView
s is pretty well documented.What you might have seen, and is quite common, is something that looks like a widget but is in reality a launcher feature. For example the HTC sense widgets. These can have different sizes for one single widget entry from the menu, listviews and some other things. Thats because they are using the sense launcher in an undocumentated way that is not useable by external devs. Often you can find out if the widget in question is a real widget by placing it using a different launcher (e.g. the android stock launcher). This can't be done with these 'special' widgets, they will show an error.