android - How to set gradient dynamically in a appwidget imageView background? -
i have set gradient in drawable\skycolor.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <gradient android:angle="90" android:endcolor="#ff5bdddd" android:startcolor="#ff4688bf" android:type="linear" /> </shape> </item>
i want set gradient background of homescreen widget. have imageview placed in widget.
<imageview android:layout_width="fill_parent" android:layout_height="match_parent" android:id="@+id/iv_background" android:layout_centervertical="true" android:layout_centerhorizontal="true" android:focusableintouchmode="true" />
how set gradient background color in updateappwidget method? planned way, did not work.
imageview iv_skycolor = (imageview)findviewbyid(r.id.iv_background); iv_skycolor.setbackground(@drawable/skycolor);
findviewbyid not work inside updateappwidget method,
updateappwidget(context context, appwidgetmanager appwidgetmanager, int appwidgetid)
also code can not resolve @drawable/skycolor. how can resolve this?
nevermind, managed make work using,
views.setimageviewresource(r.id.iv_background, r.drawable.skycolor);
Comments
Post a Comment