Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 684
Usman Kurd Avatar asked Sep 04 '12 11:09

Usman Kurd


People also ask

How do you repeat a picture on android?

Yes, its possible. Define your repeating image as Drawable (bitmap) with android:tileMode="repeat" in XML and use it as background of your RelativeLayout . Save this answer. Show activity on this post.

Can ImageView be clickable?

You can make a view clickable, as a button, by adding the android:onClick attribute in the XML layout. For example, you can make an image act like a button by adding android:onClick to the ImageView .

What is difference between ImageView and ImageButton?

ImageButton has the same property as ImageView . Only one feature is extra, which is, images set through ImageButton are clickable, and actions can be attached with them upon clicking. Just like a button, the setOnClickListener() can be used to set an event listener for click event on this.


1 Answers

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" /> 
like image 145
Anirudh Avatar answered Sep 23 '22 21:09

Anirudh