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...
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
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With