krinn
krinn

Reputation: 892

android background repeat-y

I have an image that I want to position in the right and repeat it on y axis. Something like "background: url(img.png) right repeat-y" in HTML.

Is it possible to do this in android?

When I set this bitmap as a background it's not in the right:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
  android:src="@drawable/img_list"
  android:filter="true"
  android:dither="true"
  android:tileMode="repeat"
  android:gravity="right" />

Upvotes: 4

Views: 7550

Answers (1)

Luciano
Luciano

Reputation: 2798

I use the following code for repeating a image on y axis as background:

 <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/background"
        android:tileMode="repeat"
        android:antialias="true"
        android:dither="false"
        android:filter="false"
        android:gravity="left"
    />

For seperate TileModes for X and Y u need to do this in code:

    BitmapDrawable TileMe = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.listbackground));
      //TileMe.setTileModeX(TileMode.REPEAT);
      TileMe.setTileModeY(TileMode.REPEAT);

Upvotes: 2

Related Questions