fix View Background Repeat - Android User Interface

Android examples for User Interface:View Background

Description

fix View Background Repeat

Demo Code


//package com.java2s;

import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;

import android.view.View;

public class Main {
    public static void fixBackgroundRepeat(View view) {
        if (view != null) {
            BitmapDrawable background = (BitmapDrawable) view
                    .getBackground();//  w  w w.  ja  va  2  s .  c  o  m
            if (background != null) {
                background.mutate();
                background.setTileModeXY(Shader.TileMode.REPEAT,
                        Shader.TileMode.REPEAT);
            }
            view.requestLayout();
        }
    }
}

Related Tutorials