I have set a background image in my app, but the background image is small and I want it to be repeated and fill in the whole screen. What should I do?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:tileMode="repeat">
There is a property in the drawable xml to do it. android:tileMode="repeat"
See this site: http://androidforbeginners.blogspot.com/2010/06/how-to-tile-background-image-in-android.html
Ok, here's what I've got in my app. It includes a hack to prevent
ListView
s from going black while scrolling.drawable/app_background.xml:
values/styles.xml:
AndroidManifest.xml:
Expanding on plowman's answer, here is the non-deprecated version of changing the background image with java.
Here is a pure-java implementation of background image repeating:
In this case, our background image would have to be stored in res/drawable/bg_image.png.