更改小部件上的 TextView 填充动态
我尝试更改放置在小部件上的 TextView 的填充。 直接通过“findViewById”是不可能的,因为该类是从 AppWidgetProvider 扩展的。
因此我尝试将remoteViews.setBundle与以下内容一起使用 代码。但这不是解决方案。
Bundle b = new Bundle(4);
b.putInt("left", 5);b.putInt("top", 5);b.putInt("right",
5);b.putInt("bottom", 5);
remoteViews.setBundle(R.id.name1, "setPadding", b);
有人能为我提供解决方案吗?
I tried to change the padding of a TextView which is placed on a widget.
Direct via 'findViewById' it isn't possible because the class extends from AppWidgetProvider.
Therefore I tried to use remoteViews.setBundle with the following
code. But this is not a solution.
Bundle b = new Bundle(4);
b.putInt("left", 5);b.putInt("top", 5);b.putInt("right",
5);b.putInt("bottom", 5);
remoteViews.setBundle(R.id.name1, "setPadding", b);
Does anyone have a solution for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能这样做。如果你查看 android 源代码,setPadding 方法没有标记为“@RemotableViewMethod”,这允许它的值由 RemoteViews 对象设置。我们发现的唯一技巧是使用不同的布局。
You cannot do this. If you look at the android source the setPadding method is not marked with "@RemotableViewMethod" which allows it's value to be set by the RemoteViews object. The only hack we found was to use a different layout.