public static Drawable generateCircleBgDrawable(float width, int color) {
Shape arcShape = new ArcShape(0, 360);
ShapeDrawable shopDrawablePress = new ShapeDrawable(arcShape);//圆形shape
shopDrawablePress.getPaint().setColor(color);//设置颜色
shopDrawablePress.getPaint().setStyle(Paint.Style.STROKE);//设置颜色
shopDrawablePress.getPaint().setStrokeWidth(width);//设置颜色
return shopDrawablePress;
}
java类android.graphics.drawable.shapes.ArcShape的实例源码
ResUtil.java 文件源码
项目:RLibrary
阅读 47
收藏 0
点赞 0
评论 0
PaletteGridAdapter.java 文件源码
项目:color-picker
阅读 23
收藏 0
点赞 0
评论 0
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View view = convertView;
if (view == null)
{
/*
* TODO: build the layout programmatically
*/
view = mLayoutInflater.inflate(R.layout.org_dmfs_colorpickerdialog_palette_field, null);
}
// set the background to a colored circle
// TODO: allow to customize the shape
Shape shape = new ArcShape(0, 360);
ShapeDrawable bg = new ShapeDrawable(shape);
bg.getPaint().setColor(mPalette.colorAt(position));
if (android.os.Build.VERSION.SDK_INT < 16)
{
view.setBackgroundDrawable(bg);
}
else
{
view.setBackground(bg);
}
return view;
}