Did you find a solution to this?

On 4 Juli, 13:52, Francois DESLANDES <[email protected]> wrote:
> Hello everybody,
>
> I am working a widget…
>
> I'd like to change my widget background image dynamically, is it possible ?
>
> I tried theme & style, it doesn't want to work. It doesn't show any
> background image (see code sample below)
>
> I tried RemoteViews.setImageViewResource on an ImageView filling the widget,
> but i doesn't strech my 9patch image correctly (and it doesn't seems to
> change background, it add another image).
>
> Is there a solution ?
>
> Additionnal question : is it possible to use an external (sdcard) 9patch
> image as background ? if yes : how ?
>
> Thanks
>
> My test with Themes :
>
> -------------------------
>
> layout.xml
>
> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
>
> android:id="@+id/widget"
>
> android:layout_width="wrap_content"
>
> android:layout_height="wrap_content"
>
> android:focusable="true"
>
> style="?attr/widgetBackground"
>
>
>
> ....
>
> -------------------------
>
> attrbs.xml
>
> <resources>
>
> <attr name="widgetBackground" format="reference" />
>
> </resources>
>
> -------------------------
>
> styles.xml
>
> <resources>
>
> <style name="ThemeKxDark" parent="@android:style/Theme">
>
> <item name="widgetBackground">@style/blackBackground</item>
>
> </style>
>
> <style name="ThemeKxLight" parent="@android:style/Theme">
>
> <item name="widgetBackground">@style/whiteBackground</item>
>
> </style>
>
> <style name="whiteBackground">
>
> <item name="android:background">@drawable/widget_bg_normal_white</item>
>
> </style>
>
> ...
>
> -------------------------
>
> widget code
>
> public void onUpdate(Context context, AppWidgetManager appWidgetManager,
> int[] appWidgetIds) {
>
> // If no specific widgets requested, collect list of all
>
> if (appWidgetIds == null) {
>
> appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context,
> LargeAppWidget.class));
>
> }
>
> context.setTheme(R.style.ThemeKxLight);
>
> // Request update for these widgets and launch updater service
>
> UpdateService.requestUpdate(appWidgetIds);
>
> context.startService(new Intent(context, UpdateService.class));
>
>
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to