• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Change Widget Background from Code

Matt M

Lurker
Apr 29, 2010
5
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.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones