Remote viewing and setGravity

I have an Android widget that displays a TextView in a FrameLayout . TextView fills the entire parent layout. What I want to do, it will be able to change at runtime, where the text appears in the TextView .

I would currently do this by changing the gravity in the TextView ... It even has a setGravity(int) method that should work fine with RemoteView (I'm in the widget, remember?). In theory, anyway.

Unfortunately, this happens with an error. Something about "can't run setGravity(int) here" or sth. Will be updated with an accurate error message if necessary

I am using this snippet:

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

Has anyone tried this before and have any ideas?

+4
source share
1 answer

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

Regards, StΓ©phane

+2
source

All Articles