Note that there are some explanatory texts on larger screens.

plurals
  1. POBackground Image Not Tiled Correctly when Device is Rotated
    text
    copied!<p>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.</p> <p>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.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/bgimg" android:tileMode="repeat" /&gt; </code></pre> <p>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:</p> <pre><code>&lt;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" &gt; &lt;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" &gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" &gt; text views buttons etc &lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;/LinearLayout&gt; </code></pre> <p>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.</p> <p>I have an activity (not fragment) that uses the same background in its main LinearLayout (as opposed to ScrollView) and this activity works fine.</p> <p>I do not have any code to handle the background image, just the XML files.</p> <p>If I preview the fragment in Eclipse, then rotate, it behaves OK.</p> <p>The layout file is in the "layout" folder. I do not have a folder for "layout-land".</p> <p>The device I tested on is Samsung Galaxy (GT-I9000) with Android 2.2 (I haven't tested on other devices yet).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload