Example usage for android.graphics.drawable BitmapDrawable mutate

List of usage examples for android.graphics.drawable BitmapDrawable mutate

Introduction

In this page you can find the example usage for android.graphics.drawable BitmapDrawable mutate.

Prototype

@Override
public Drawable mutate() 

Source Link

Document

A mutable BitmapDrawable still shares its Bitmap with any other Drawable that comes from the same resource.

Usage

From source file:Main.java

/**
 * from http://stackoverflow.com/questions/4336286/tiled-drawable-sometimes-stretches/9500334#9500334
 *//*  www.java2 s . c o m*/
public static void fixBackgroundRepeat(View view) {
    Drawable bg = view.getBackground();
    if (bg != null) {
        if (bg instanceof BitmapDrawable) {
            BitmapDrawable bmp = (BitmapDrawable) bg;
            bmp.mutate(); // make sure that we aren't sharing state anymore
            bmp.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        }
    }
}