setAlpha为RemoteViews问题问题、setAlpha、RemoteViews

2023-09-07 10:52:25 作者:悔及当初

我在做一个appwidget,而且也对小部件的位图,其中我想改变它的透明度。

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

在我的服务有:

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

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

不过,这是行不通的。仿真器显示问题加载插件在主屏幕上。 我是pretty的肯定一切是好的COS时,我改了行,以改变它的imageResource它完美运行: remoteView.setInt(R.id.widgetPNG,setImageResource,R.drawable。 anotherPNG)。

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...

推荐答案

上午冒牌货,你只能叫 SETINT()和API的朋友这是标有 @RemotableViewMethod 标注在Android源$ C ​​$ C(example).怕 setAlpha()是不是其中之一。

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...

 
精彩推荐
图片推荐