开发者

RemoteView and setGravity

I've got an android widget, that displays a TextView in a FrameLayout. The TextView fills the whole parent layout. What I want to do, it be able to change at runtime where will the text will appear within the TextView开发者_如何学编程.

Currently, I'd do it by changing the gravity on the TextView... It even has a setGravity(int) method, which should work perfectly with a RemoteView (I'm in a widget, remember?).. In theory anyway.

Unfortunately, this comes back with an error. Something about "cannot run setGravity(int) here" or sth. Will update with the exact error message if needed

I'm using this snippet:

myRemoteView.setInt(R.id.myTextView, "setGravity", myGravity);

Anyone tried this before, and has any ideas?


It should work but, if not, maybe you could have two textviews and switch the visibility from GONE to VISIBLE to get the text at the right place.

Regards, Stéphane

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜