Search code examples
androidbitmapandroid-imageviewandroid-relativelayout

Repeat Image in with ImageView in RelativeLayout


I want to repeat the image with ImageView with in RelativeLayout. Can it be possible to use the Bitmap xml and use tilemode "repeat" with RelativeLayout, because what I have seen things on Internet they all dealing with LinearLayout.

Any help or tip will be warmly welcomed.


Solution

  • Create an XML file named background in Drawable folder

    background.xml

    <?xml version="1.0" encoding="utf-8"?>
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/imagename"
    android:tileMode="repeat" />
    

    In your Relative Layout add the above XML as background

    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY"
    android:background="@drawable/background" />