Change Widget Background from Code


Last Updated:

  1. Matt M

    Matt M Member This Topic's Starter

    Joined:
    Apr 29, 2010
    Messages:
    5
    Likes Received:
    0
    Hello,

    I am trying to allow the user to change the widget background color (black, white, transparent). Instead of adding numerous xml files each linking to a different background image, is there anyway I can go about changing the widget background image through code? For example, using LinearLayout

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android;orientation="vertical"
    style="@style/WidgetBackground2x2">

    Is there any way I can set the "style" attribute from the code? I know this method does not exist but something along these lines:
    LinearLayout.setStyle(R.style.WidgetBackground2x2_transparent);

    Thank you!

    Matt.
     

    Advertisement

Share This Page

Loading...