add Padding Around to Drawable - Android Graphics

Android examples for Graphics:Drawable Operation

Description

add Padding Around to Drawable

Demo Code


//package com.java2s;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;

public class Main {
    public static Drawable addPaddingArround(int padding, Drawable drawable) {
        LayerDrawable withPadding = new LayerDrawable(
                new Drawable[] { drawable });
        withPadding.setLayerInset(0, padding, padding, padding, padding);
        return withPadding;
    }/*  w w w.jav  a 2s .c  om*/
}

Related Tutorials