kiturk3
kiturk3

Reputation: 558

Change background color of remoteview dynamically

As of my previous question here I successfully managed to do this by transparent image. Now i want to change background color of images dynamically in remoteviews(PS I want to make widget like that and color of images in given link changes dynamically).

I tried following code:

ColorFilter cf = new PorterDuffColorFilter(-15032095, Mode.MULTIPLY);
        Drawable d= context.getResources().getDrawable(R.drawable.panel1);
        d.mutate();
        d.setColorFilter(cf);
        rv.setBitmap(R.id.rl_noti_main, "setColorFilter", drawableToBitmap(d));

but it didn't help. How can i achieve this? I have color codes in all formats integer, HEX or string whatever it will be needed. Please note that i want to do this only for given shapes in this link and for remoteview.

Thanks in Advance :)

Upvotes: 1

Views: 3338

Answers (2)

Brave Dolphin
Brave Dolphin

Reputation: 152

For someone else looking for it

remoteView.setInt(R.id.container, "setBackgroundColor", backgroundColor);

Upvotes: 4

tasomaniac
tasomaniac

Reputation: 10342

You cannot dynamically update widgets.

You can use the setBitmap() method to change the bitmap of a view inside a RemoteView. If the view is at the background, it should change the background. And then update the widget to make the changes to be applied.

If you are using RemoteViews in Notifications, you should update your notification after this. If you are using it in a Widget, you should use appWidgetManager.updateAppWidget(appWidgetId, views); function.

Upvotes: 0

Related Questions