How to put multiple widget sizes in one apk?(如何将多个小部件尺寸放在一个 apk 中?)
问题描述
我想要做的是在一个 apk 中拥有一个不同大小(即 2x2、3x3、4x4 等)的时钟小部件,以及一个能够选择要添加的大小的配置活动.
What I'm trying to do is have a clock widget of different sizes (i.e. 2x2, 3x3, 4x4 etc) in one apk and a configuration activity to be able to select which size to add.
根据我从文档中学到的知识:
From what i've learned from documentation:
- 小部件大小在 <appwidget-provider> 中指定.相应xml文件中的标记
- 我还在该文件中为该提供者设置了配置活动
所以似乎大小是 AppWidgetProvider 的一个属性,我需要以某种方式从第一个配置活动中的代码创建另一个提供程序...还是我弄错了,还有其他方法?
So it seems that size is a property of AppWidgetProvider and I'll need to somehow create another provider from the code in configuration Activity of the first one... Or am I getting this wrong and there's another way?
这可能吗?:)我被告知有些小部件可以做到这一点:)
Is this possible at all? :) I've been told that some widgets can do this :)
提前致谢!
附:我已阅读 this 和 这个.第一个解释了如何在一个 apk 中放置多个 wigets,但不清楚如何在运行时在它们之间进行选择.第二个是关于改变布局,但不是大小......
P.S. I have read this and this. First one explains how to put multiple wigets in one apk, but it's not clear how to select between them in runtime. Second one is about changing layouts, but not size...
推荐答案
您真的必须在运行时执行此操作吗? 可以在一个 .apk 中定义多个小部件.
Do you really have to do this at runtime? It is possible to define several widgets in one .apk.
也许你可以看看 transdroid 源码?它们在同一个包中包含两种尺寸的小部件.
Maybe you can have a look on transdroid source? They are including two sizes of a widget in the same package.
由 Transdroid 使用
AndroidManifest.xml used by Transdroid
这篇关于如何将多个小部件尺寸放在一个 apk 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将多个小部件尺寸放在一个 apk 中?


- 网上有没有好的 UIScrollView 教程? 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- UITextView 内容插图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- URL编码Swift iOS 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01