本文介绍了Google日历颜色选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有基于系统的方法来调用其中一个颜色选择器,就像在Google日历应用程序?
is there a system based method to call one of those color pickers, like in the Google Calendar app? Or do I have it to build it on my own?
推荐答案
您需要使用。
实施:
ColorPickerDialog colorcalendar = ColorPickerDialog.newInstance(
R.string.color_picker_default_title,
mColor,
mSelectedColorCal0,
5,
Utils.isTablet(this)? ColorPickerDialog.SIZE_LARGE : ColorPickerDialog.SIZE_SMALL);
//Implement listener to get selected color value
colorcalendar.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener(){
@Override
public void onColorSelected(int color)
{
// ADD MARKER
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_mobileedge_navpoint);
bmp = changeBitmapColor(bmp, color);
googleMap.addMarker(new MarkerOptions()
.position(latLng)
.title("My Spot")
.snippet("This is my spot!")
.icon(BitmapDescriptorFactory.fromBitmap(bmp)));
}
});
colorcalendar.show(getFragmentManager(),"cal");
更改位图颜色的功能:
private Bitmap changeBitmapColor(Bitmap sourceBitmap, int color) {
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0,
sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1);
Paint p = new Paint();
ColorFilter filter = new LightingColorFilter(color, 1);
p.setColorFilter(filter);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawBitmap(resultBitmap, 0, 0, p);
return resultBitmap;
}
我测试了,它工作正常!标记必须是全白的阿尔法,只有那么颜色将是完美的!
I tested and it worked fine! The marker has to be all white with alpha, only then is that the colors will be perfect!
这篇关于Google日历颜色选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!