本文介绍了ImageView 实现Android colorPikcer 选择器的示例代码,分享给大家,具体如下:Android colorPikcer 选择器环形的ColorPicker,主要思路是: Color 选在放在ImageVi
本文介绍了ImageView 实现Android colorPikcer 选择器的示例代码,分享给大家,具体如下:
Android colorPikcer 选择器
环形的ColorPicker,主要思路是:
获取Bitmap
在 ColorPickerView 构造函数中初始化 Bitmap。因为getBackground有多种drawable,然后获取Bitmap 的方式也不用,
void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr){ Drawable drawable = getBackground(); if(drawable instanceof BitmapDrawable){ mBitmap = ((BitmapDrawable) drawable).getBitmap(); } else if(drawable instanceof VectorDrawable){ mBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); canvas vectorCanvas = new Canvas(mBitmap); drawable.setBounds(0, 0, vectorCanvas.getWidth(), vectorCanvas.getHeight()); drawable.draw(vectorCanvas); }
--结束END--
本文标题: ImageView 实现Android colorPikcer 选择器的示例代码
本文链接: https://www.lsjlt.com/news/220649.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-14
2024-05-14
2024-05-14
2024-05-14
2024-05-14
2024-05-14
2024-05-14
2024-05-14
2024-05-14
2024-05-14
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0