List of usage examples for android.graphics.drawable GradientDrawable setCornerRadius
public void setCornerRadius(float radius)
From source file:Main.java
public static Drawable createRoundRectShape(int corner, int color) { GradientDrawable drawable = new GradientDrawable(); drawable.setCornerRadius(corner); drawable.setColor(color);/* w w w . j a va 2s . c om*/ return drawable; }
From source file:Main.java
public static GradientDrawable getDrawable(int radius, int fillColor, int width, int strokeColor) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setCornerRadius(radius); gradientDrawable.setColor(fillColor); gradientDrawable.setStroke(width, strokeColor); return gradientDrawable; }
From source file:Main.java
public static GradientDrawable createBackgroundRandom() { Random rnd = new Random(); int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); GradientDrawable gd = new GradientDrawable(); gd.setColor(color);//from w ww . ja v a 2 s .c o m gd.setCornerRadius(5); gd.setAlpha(90); return gd; }
From source file:Main.java
public static Drawable cornerDrawable(final int bgColor, float cornerradius) { final GradientDrawable bg = new GradientDrawable(); bg.setCornerRadius(cornerradius); bg.setColor(bgColor);/*from ww w.ja va2s . co m*/ return bg; }
From source file:Main.java
/** * * @param radius//from ww w. j av a 2s . co m * @return * @deprecated Change to use ViewUtils. */ @Deprecated public static GradientDrawable getShapeDrawable(float radius) { GradientDrawable shape = new GradientDrawable(); shape.setColor(Color.TRANSPARENT); shape.setCornerRadius(radius); return shape; }
From source file:Main.java
public static void makeRoundCorner(View v, int color, int radius) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setColor(color);// w w w .ja v a2s. c o m gradientDrawable.setCornerRadius(radius); if (Build.VERSION.SDK_INT < 16) v.setBackgroundDrawable(gradientDrawable); else v.setBackground(gradientDrawable); }
From source file:Main.java
public static Drawable createRandomColorShapeDrawable() { GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setCornerRadius(5); drawable.setColor(createRandomColor()); return drawable; }
From source file:Main.java
public static GradientDrawable getShape(float radius, int color) { GradientDrawable gd = new GradientDrawable(); // gd.setShape(GradientDrawable.OVAL); The larger the radius, the more round the radius gd.setCornerRadius(radius); gd.setColor(color);//w w w . ja va 2 s . c o m return gd; }
From source file:Main.java
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);//from w ww . jav a 2s . c om return drawable; }
From source file:com.waz.zclient.ui.utils.ColorUtils.java
public static Drawable getButtonBackground(int borderColor, int fillColor, int strokeWidth, int cornerRadius) { int fillColorPressed = getPressColor(PRESSED_ALPHA, fillColor); int borderColorPressed = getPressColor(PRESSED_ALPHA, borderColor); GradientDrawable gradientDrawablePressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { fillColorPressed, fillColorPressed }); gradientDrawablePressed.setStroke(strokeWidth, borderColorPressed); gradientDrawablePressed.setCornerRadius(cornerRadius); GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { fillColor, fillColor }); gradientDrawable.setStroke(strokeWidth, borderColor); gradientDrawable.setCornerRadius(cornerRadius); StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_pressed }, gradientDrawablePressed); states.addState(new int[] { android.R.attr.state_focused }, gradientDrawablePressed); states.addState(new int[] {}, gradientDrawable); return states; }