sdittmann
asked on
Dynamical change the background resouce
Hello,
I'm currently setting the background parent resource, and only layout, like this which works:
// Set background through the preferences if (prefs.getString("listPref ", "").equals("RedHouse")) { linearLayout = (LinearLayout) this.findViewById(R.id.Lin earLayout0 1); linearLayout.startAnimatio n(myFadeIn Animation) ; // Set animation to linearLayout.setBackground Resource(R .drawable. redhouse); }
I want to use ViewFlipper or some other widget to flip through multiple red house png files without disrupting the textviews.
I attempted the below code snippet but I couldn't get the LinearLayout background set.
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="verti cal" android:layout_width="fill _parent"
android:layout_height="fil l_parent" android:id="@+id/LinearLay out01">
<TextView android:id="@+id/textview" android:textSize="20dip"
android:layout_width="fill _parent" android:layout_height="wra p_content"
android:text="TEST!!!" android:background="#0000f f" />
<TextView android:gravity="center_ve rtical|cen ter_horizo ntal"
android:id="@+id/textview1 " android:textSize="100sp"
android:textColor="#ffffff 00"
android:layout_width="fill _parent"
android:layout_height="wra p_content" android:text="100"
android:layout_gravity="ce nter_horiz ontal" />
<ViewFlipper android:id="@+id/ViewFlipp er01"
android:layout_width="fill _parent" android:layout_height="fil l_parent">
<!--adding views to ViewFlipper-->
<ImageView android:id="@+id/ImageView 01" android:layout_width="fill _parent"
android:layout_height="fil l_parent" android:text="Flipper Content 1" android:src="@drawable/red house"></I mageView>
<ImageView android:id="@+id/ImageView 02" android:layout_width="fill _parent"
android:layout_height="fil l_parent" android:text="Flipper Content 2" android:src="@drawable/red house1"></ ImageView>
<ImageView android:id="@+id/ImageView 03" android:layout_width="fill _parent"
android:layout_height="fil l_parent" android:text="Flipper Content 3"></ImageView>
</ViewFlipper>
</LinearLayout>
java file: public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.ma in);
flipper = (ViewFlipper) findViewById(R.id.ViewFlip per01);
flipper.setFlipInterval(20 00);
flipper.startFlipping();
}
}
The above behavior will show the images underneath the TextView of "100". It needs to be set the entire background of the activity so that the TextView is on top. I attempted to put the TextView inside of the ViewFlipper but that didn't get the desired behavior.
Any ideas?
Thanks in advance.
I'm currently setting the background parent resource, and only layout, like this which works:
// Set background through the preferences if (prefs.getString("listPref
I want to use ViewFlipper or some other widget to flip through multiple red house png files without disrupting the textviews.
I attempted the below code snippet but I couldn't get the LinearLayout background set.
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="verti
android:layout_height="fil
<TextView android:id="@+id/textview"
android:layout_width="fill
android:text="TEST!!!" android:background="#0000f
<TextView android:gravity="center_ve
android:id="@+id/textview1
android:textColor="#ffffff
android:layout_width="fill
android:layout_height="wra
android:layout_gravity="ce
<ViewFlipper android:id="@+id/ViewFlipp
android:layout_width="fill
<!--adding views to ViewFlipper-->
<ImageView android:id="@+id/ImageView
android:layout_height="fil
<ImageView android:id="@+id/ImageView
android:layout_height="fil
<ImageView android:id="@+id/ImageView
android:layout_height="fil
</ViewFlipper>
</LinearLayout>
java file: public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.ma
flipper = (ViewFlipper) findViewById(R.id.ViewFlip
flipper.setFlipInterval(20
flipper.startFlipping();
}
}
The above behavior will show the images underneath the TextView of "100". It needs to be set the entire background of the activity so that the TextView is on top. I attempted to put the TextView inside of the ViewFlipper but that didn't get the desired behavior.
Any ideas?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.