![](/img/trans.png)
[英]How to change the background's color of an ImageView in RemoteViews without changing its shape?
[英]How to change widget background using RemoteViews?
<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);
但我隨后顯示“Widget無法加載”
它必須作為背景,因為我需要在圖像的中心設置一個文本:)
你在RelativeLayout
上調用setImageViewBitmap
。 RelativeLayout
不是ImageView
。 您可以在其中放置一個ImageView
,而不是填充RelativeLayout
並在其上調用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.