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 h开发者_开发知识库ome 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...
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...
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
精彩评论