I have app widget with TextView in it.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/widgetText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/defaultWidgetText"
android:gravity="center"
/>
</FrameLayout>
I’m trying to change text alignment by calling
views.setInt(R.id.widgetText, "setGravity", Gravity.CENTER);
from RemoteView. But it makes “Problem loading widget”
Other setInt(…) works fine.
I don’t want create another TextViews or Layouts. Is there any other way to change Gravity ?
So… Here is my solution.
Widget layout:
And onUpdate(…) method:
P.S. I know, this is a bad coding style, but other variants in Internet looks the same = (