I am having problem keeping a background in repeating tile mode when device is rotated. When I rotate a device, the background goes from repeated tiles to stretched image.
The background is a drawable XML (bg.xml). This XML has a bitmap that is a small PNG file, with tile mode set to repeat.
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/bgimg"
android:tileMode="repeat" />
Now a fragment inflates a particular layout. This layout has a ScrollView. This ScrollView has the background set to the bg.xml file mentioned above. The layout file looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="8dip"
android:layout_marginRight="8dip"
android:layout_weight="1"
android:background="@drawable/bg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
text views
buttons
etc
</LinearLayout>
</ScrollView>
</LinearLayout>
If the fragment is firstly shown in either landscape or portrait mode, the background image is tiled as expected. However, as soon as the device is rotated while the fragment is being shown, the background image stretches and is no longer tiled.
I have an activity (not fragment) that uses the same background in its main LinearLayout (as opposed to ScrollView) and this activity works fine.
I do not have any code to handle the background image, just the XML files.
If I preview the fragment in Eclipse, then rotate, it behaves OK.
The layout file is in the "layout" folder. I do not have a folder for "layout-land".
The device I tested on is Samsung Galaxy (GT-I9000) with Android 2.2 (I haven't tested on other devices yet).