开发者

Change TextView padding dynamic on widget

开发者 https://www.devze.com 2023-01-24 08:28 出处:网络
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.

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, &q开发者_如何学Cuot;setPadding", b);

Does anyone have a solution for me?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消