get Corner Radii Drawable - Android Graphics

Android examples for Graphics:Drawable Operation

Description

get Corner Radii Drawable

Demo Code


//package com.java2s;

import android.graphics.Canvas;

import android.graphics.drawable.GradientDrawable;

public class Main {
    public static GradientDrawable getCornerRadiiDrawable(float radius,
            int color) {
        GradientDrawable drawable = new GradientDrawable();
        drawable.setCornerRadii(new float[] { radius, radius, radius,
                radius, radius, radius, radius, radius });
        drawable.setColor(color);//from   w  w  w  .  ja  v a2 s. c o m
        return drawable;
    }

    public static GradientDrawable getCornerRadiiDrawable(float[] radii,
            int color) {
        GradientDrawable drawable = new GradientDrawable() {
            @Override
            public void draw(Canvas canvas) {
                super.draw(canvas);
            }
        };
        drawable.setCornerRadii(radii);
        drawable.setColor(color);
        return drawable;
    }
}

Related Tutorials