slezadav
slezadav

Reputation: 6141

Android : Repeating background stops repeating on rotation

my problem is following : On rotation, my background which is made of repeating pattern changes so that the pattern is stretched instead of repeating. What could possibly be wrong ?

I have this background made of repeating pattern:

< bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/pattern" android:tileMode="repeat" />

Upvotes: 1

Views: 204

Answers (1)

user1649031
user1649031

Reputation:

You have to set repeating pattern manually :

parent = (RelativeLayout) findViewById(R.id.log_parent);
    Bitmap bg = BitmapFactory.decodeResource(this.getResources(), R.drawable.pattern);
    BitmapDrawable patternRepeat = new BitmapDrawable(bg);
    patternRepeat.setTileModeX(Shader.TileMode.REPEAT);
    patternRepeat.setTileModeY(Shader.TileMode.REPEAT);
    parent.setBackgroundDrawable(patternRepeat);

Upvotes: 1

Related Questions