yozcaliskan
yozcaliskan

Reputation: 31

How to update ImageButton BackgroundColor in RemoteViews

I have an appwidget which has got a ImageButton.I can update ImageButton image but i can't update backgroundcolor with using setInt() method;because imagebutton setBackgroundColor is not annoated with RemotableViewMethod.class.What can i do else?

Upvotes: 0

Views: 1320

Answers (3)

Joe
Joe

Reputation: 1

You can use ImageView instead of layout background, we can set ImageView src to change background (may be you will use android:scaleType="fitXY")

Upvotes: 0

plugmind
plugmind

Reputation: 7986

http://developer.android.com/reference/android/widget/RemoteViews.html#setInt%28int,%20java.lang.String,%20int%29

Example:

rv.setInt(R.id.view_id, "setBackgroundColor", 0xFF0000FF);

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1006869

You can try using a different layout in your RemoteViews constructor that has the right background color. You create a RemoteViews object on every update, and you tell that RemoteViews object what layout to use. From my testing, if you inflate something different than before, that will replace what the app widget presently uses. The various RemoteViews setters are for things that you cannot readily handle via layouts (e.g., dynamic text for a TextView).

Upvotes: 1

Related Questions