public static Drawable createBgDrawable(int color, int rTopLeft,
int rTopRight, int rBottomRight,
int rBottomLeft) {
float[] outerRadii = new float[8];
outerRadii[0] = rTopLeft;
outerRadii[1] = rTopLeft;
outerRadii[2] = rTopRight;
outerRadii[3] = rTopRight;
outerRadii[4] = rBottomRight;
outerRadii[5] = rBottomRight;
outerRadii[6] = rBottomLeft;
outerRadii[7] = rBottomLeft;
RoundRectShape r = new RoundRectShape(outerRadii, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(r);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
}
java类android.graphics.drawable.shapes.RoundRectShape的实例源码
SUtils.java 文件源码
项目:CheckSmarter
阅读 38
收藏 0
点赞 0
评论 0
DotWidget.java 文件源码
项目:FriendCircle
阅读 26
收藏 0
点赞 0
评论 0
private ShapeDrawable getDotBackground() {
ShapeDrawable drawable = null;
switch (mode) {
case ROUND_RECT:
int radius = dip2Pixels(dotRadius);
float[] outerRect = new float[] { radius, radius, radius, radius, radius, radius, radius, radius };
RoundRectShape rr = new RoundRectShape(outerRect, null, null);
drawable = new InnerShapeDrawableWithText(rr, dotText);
drawable.getPaint().setColor(dotColor);
break;
case CIRCLE:
OvalShape os = new OvalShape();
drawable = new InnerShapeDrawableWithText(os, dotText);
drawable.getPaint().setColor(dotColor);
// int paddingPixels = dip2Pixels(8);
// drawable.setPadding(paddingPixels, paddingPixels, paddingPixels,
// paddingPixels);
break;
}
return drawable;
}
CustomToast.java 文件源码
项目:Newton_for_Android_AS
阅读 33
收藏 0
点赞 0
评论 0
public CustomToast(Context context) {
// 此处必须是ApplicationContext,因为Activity退出也可以显示
context = context.getApplicationContext();
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
rootView = new LinearLayout(context);
// 背景设置为圆角矩形
float r = 10;
float[] outerR = new float[] { r, r, r, r, r, r, r, r };
RoundRectShape rr = new RoundRectShape(outerR, null, null);
ShapeDrawable drawable = new ShapeDrawable(rr);
drawable.getPaint().setColor(Color.BLACK);
int a = UIUtil.dip2px(context, 10);
drawable.setPadding(a, a, a, a);
rootView.setBackgroundDrawable(drawable);
}
MiddleLinesDialog.java 文件源码
项目:MiddleLinesDialogUtils
阅读 36
收藏 0
点赞 0
评论 0
@NonNull
private ShapeDrawable getShapeDrawable(int topLeftAndRightRadius, int bottomLeftAndRightRadius, int bgColor) {
float outRectr[] = new float[]{
topLeftAndRightRadius, topLeftAndRightRadius,
topLeftAndRightRadius, topLeftAndRightRadius,
bottomLeftAndRightRadius, bottomLeftAndRightRadius,
bottomLeftAndRightRadius, bottomLeftAndRightRadius};
/**
* 注意StateListDrawable的构造方法我们这里使用的
* 是第一参数它是一个float的数组保存的是圆角的半径,它是按照top-left顺时针保存的八个值
*/
//创建圆弧形状
RoundRectShape rectShape = new RoundRectShape(outRectr, null, null);
//创建drawable
ShapeDrawable pressedDrawable = new ShapeDrawable(rectShape);
//设置背景的颜色
pressedDrawable.getPaint().setColor(bgColor);
return pressedDrawable;
}
Label.java 文件源码
项目:clear-todolist
阅读 31
收藏 0
点赞 0
评论 0
private Drawable createRectDrawable(int color) {
RoundRectShape shape = new RoundRectShape(
new float[]{
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius
},
null,
null);
ShapeDrawable shapeDrawable = new ShapeDrawable(shape);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
}
Label.java 文件源码
项目:neveshtanak-Deprecated-
阅读 28
收藏 0
点赞 0
评论 0
private Drawable createRectDrawable(int color) {
RoundRectShape shape = new RoundRectShape(
new float[]{
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius
},
null,
null);
ShapeDrawable shapeDrawable = new ShapeDrawable(shape);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
}
SUtils.java 文件源码
项目:SublimePicker
阅读 22
收藏 0
点赞 0
评论 0
private static Drawable createButtonShape(Context context, int color) {
// Translation of Lollipop's xml button-bg definition to Java
int paddingH = context.getResources()
.getDimensionPixelSize(R.dimen.button_padding_horizontal_material);
int paddingV = context.getResources()
.getDimensionPixelSize(R.dimen.button_padding_vertical_material);
int insetH = context.getResources()
.getDimensionPixelSize(R.dimen.button_inset_horizontal_material);
int insetV = context.getResources()
.getDimensionPixelSize(R.dimen.button_inset_vertical_material);
float[] outerRadii = new float[8];
Arrays.fill(outerRadii, CORNER_RADIUS);
RoundRectShape r = new RoundRectShape(outerRadii, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(r);
shapeDrawable.getPaint().setColor(color);
shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);
return new InsetDrawable(shapeDrawable,
insetH, insetV, insetH, insetV);
}
SUtils.java 文件源码
项目:SublimePicker
阅读 24
收藏 0
点赞 0
评论 0
public static Drawable createBgDrawable(int color, int rTopLeft,
int rTopRight, int rBottomRight,
int rBottomLeft) {
float[] outerRadii = new float[8];
outerRadii[0] = rTopLeft;
outerRadii[1] = rTopLeft;
outerRadii[2] = rTopRight;
outerRadii[3] = rTopRight;
outerRadii[4] = rBottomRight;
outerRadii[5] = rBottomRight;
outerRadii[6] = rBottomLeft;
outerRadii[7] = rBottomLeft;
RoundRectShape r = new RoundRectShape(outerRadii, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(r);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
}
Label.java 文件源码
项目:NQH_FloatingActionButton
阅读 33
收藏 0
点赞 0
评论 0
private Drawable createRectDrawable(int color) {
RoundRectShape shape = new RoundRectShape(
new float[]{
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius
},
null,
null);
ShapeDrawable shapeDrawable = new ShapeDrawable(shape);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
}
Label.java 文件源码
项目:flowzr-android-black
阅读 36
收藏 0
点赞 0
评论 0
private Drawable createRectDrawable(int color) {
RoundRectShape shape = new RoundRectShape(
new float[]{
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius,
mCornerRadius
},
null,
null);
ShapeDrawable shapeDrawable = new ShapeDrawable(shape);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
}