Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setAlpha for RemoteViews problem

I'm making an appwidget, and there's a bitmap on the widget of which I want to change it's transparency.

In the service I have:

RemoteViews remoteView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.myWidget);

remoteView.setInt(R.id.widgetPNG, "setAlpha", 50);

But it doesn't work. The emulator shows "Problem loading widget" on the home screen. I'm pretty sure everything else is fine cos when i changed the line to change it's imageResource it runs perfectly: remoteView.setInt(R.id.widgetPNG, "setImageResource", R.drawable.anotherPNG).

Can anyone help me? I've been stuck with this for a week...

like image 400
Kinwai Avatar asked Nov 30 '10 11:11

Kinwai


2 Answers

Set image in a src of imageview in XML. In java:

 if (Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.ECLAIR_MR1) {
     rViews.setInt(R.id.imageview, "setAlpha", 30);
 }

try this one this support only available above 2.1

like image 23
ashish Avatar answered Oct 20 '22 07:10

ashish


Am fraid you can only call setInt() and friends on APIs which are marked with the @RemotableViewMethod annotation in the Android source code (example). Afraid setAlpha() is not one of them.

Maybe you could have two background images, a transparent one and a non-transparent one...

like image 157
Reuben Scratton Avatar answered Oct 20 '22 06:10

Reuben Scratton