How to repeat background image in Android Activity

If you have a tile image and want to repeat it as a background of your Android Activity screen this can be achieved using android:tileMode property, lets see an example,

  • Step 1: Select your texture image that you want to repeat,

    Example: Texture Image to Repeat
    Example: Texture Image to Repeat
  • Step 2: Create an xml under res -> drawable having bitmap tag with android:tileMode="repeat" attribute,

    Place the image in res folder
    Place the image in res folder
    <?xml version="1.0" encoding="utf-8"?>
        <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
         android:src="@drawable/texture"
         android:tileMode="repeat" />
  • Step 3: Now include this bitmap in the activity layout background attribute,

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/app_bg" >
    </RelativeLayout>
  • Result:
    Output
    Output
    Related Android Development References:

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!