如何将多个小部件尺寸放在一个 apk 中? [英] How to put multiple widget sizes in one apk?

查看:25
本文介绍了如何将多个小部件尺寸放在一个 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:

  1. 小部件大小在 <appwidget-provider> 中指定.相应xml文件中的标记
  2. 我还在该文件中为该提供者设置了配置活动

所以似乎大小是 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.

AndroidManifest.xml used by Transdroid

这篇关于如何将多个小部件尺寸放在一个 apk 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆