create Drawable Background - Android Graphics

Android examples for Graphics:Drawable

Description

create Drawable Background

Demo Code


//package com.java2s;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;

public class Main {
    public static Drawable createDrawableBackground(int color,
            int cornerRadius, boolean hasBorder, int borderThickness,
            int borderColor) {
        GradientDrawable drawable = new GradientDrawable();
        drawable.setShape(GradientDrawable.RECTANGLE);
        if (hasBorder)
            drawable.setStroke(borderThickness, borderColor);
        drawable.setCornerRadius(cornerRadius);
        drawable.setColor(color);/*  w w  w. ja va  2  s  .c  o m*/
        return drawable;
    }
}

Related Tutorials