问题描述
我想远程将TextView的高度设置为WRAP_CONTENT.
如何做到这一点,因为没有remoteviews.setLayoutParams(viewId, param)功能?
我尝试了remoteviews.setInt.(viewId, "setHeight", -2),但这只是将TextView的高度设置为零...
谢谢!
推荐答案
创建RemoteViews时,将资源ID传递给具有TextView设置为高度设置为wrap_content的构造函数的构造函数.请记住,当您发送更新时,您可以有效地重绘应用程序小部件,因此您可以使用布局文件影响您无法通过RemoteViews的方法执行的更改.
问题描述
I would like to set the height of a TextView to WRAP_CONTENT remotely.
How would I do that, since there is no remoteviews.setLayoutParams(viewId, param) function?
I tried remoteviews.setInt.(viewId, "setHeight", -2), but that just sets the height of the TextView to zero...
Thanks!
推荐答案
When you create the RemoteViews, pass in a resource ID to the constructor that has the TextView set to height set to wrap_content. Remember that when you send updates over, you are effectively redrawing the app widget, so you can use your layout files to affect changes that you cannot do via methods on RemoteViews.