create GradientDrawable from content color, stroke color, radius - Android Graphics

Android examples for Graphics:Gradient Color

Description

create GradientDrawable from content color, stroke color, radius

Demo Code


//package com.java2s;

import android.graphics.drawable.GradientDrawable;

public class Main {

    public static GradientDrawable createDrawable(int contentColor,
            int strokeColor, int radius) {
        GradientDrawable drawable = new GradientDrawable();
        drawable.setGradientType(GradientDrawable.RECTANGLE); 
        drawable.setColor(contentColor);// 
        drawable.setStroke(1, strokeColor); // ,ViewsetScrollCache(false)
        drawable.setCornerRadius(radius); // 
        return drawable;
    }/*from   w  w w.  j a  v a 2s . c o m*/
}

Related Tutorials