<RelativeLayout
android:id="@+id/widget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/my_background"
android:orientation="vertical" >
现在我想使用 RemoteViews 将这个背景更改为“@drawable/your_bck”。我试过这样的事情
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.yout_bck);
remoteViews.setImageViewBitmap(R.id.widget, bitmap);
但是我然后它显示“小部件加载失败”
它必须作为背景,因为我需要在图像的中心设置一个文本:)
最佳答案
您正在 RelativeLayout
上调用 setImageViewBitmap
。 RelativeLayout
不是 ImageView
。您可以在其中放置一个 ImageView
来填充 RelativeLayout
并在其上调用它。
关于java - 如何使用 RemoteViews 更改小部件背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8935711/