Repeat Image in with ImageView in RelativeLayout

Usman Kurd picture Usman Kurd · Sep 4, 2012 · Viewed 23.8k times · Source

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.

Answer

Anirudh picture Anirudh · Sep 11, 2012

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" />