make GradientDrawable Round Corner - Android Graphics

Android examples for Graphics:Gradient Drawable

Description

make GradientDrawable Round Corner

Demo Code


//package com.java2s;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.view.View;

public class Main {
    public static void makeRoundCorner(View v, int color, int radius) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setColor(color);
        gradientDrawable.setCornerRadius(radius);
        if (Build.VERSION.SDK_INT < 16)
            v.setBackgroundDrawable(gradientDrawable);
        else//from  w ww.j  av  a 2  s.co m
            v.setBackground(gradientDrawable);
    }
}

Related Tutorials