谷歌日历颜色选择器

5

有没有一种系统级的方法来调用这些颜色选择器,就像 Google 日历应用程序中那样?还是我需要自己构建它?

enter image description here


你需要颜色选择器做什么? - Rachel Gallen
有一个安卓颜色选择器:http://code.google.com/p/android-color-picker/ - Rachel Gallen
http://v4all123.blogspot.ie/2013/06/simple-colorpicker-for-android.html - Rachel Gallen
我需要一个能够选择Google地图标记颜色的工具,但我希望其中包含预定义的颜色,就像上面的图片一样。 - tom_tom
所以,基本上你正在寻找Color Picker Collection?该库包括股票日历应用程序中使用的颜色选择器的端口。代码示例在链接中提供。 - MH.
1个回答

5
你需要使用颜色选择器集合
实现:
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;
    }

我测试过了,一切正常!标记必须是全白带有alpha通道,只有这样才能保证颜色完美无误!


请您详细说明一下。 - prat
@prat 详细说明什么? - extmkv
我也有与上述相同的需求。您提到的库符合我的要求。您能帮我了解一下这个库的使用吗? - prat
这将是一个很大的帮助...您还可以查看我的当前问题,这将提供适当的情境。 - prat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接