【问题标题】:Google Calendar color picker谷歌日历颜色选择器
【发布时间】:2014-07-01 13:31:30
【问题描述】:

是否有基于系统的方法来调用其中一个颜色选择器,例如在 Google 日历应用程序中?还是我自己构建它?

【问题讨论】:

标签: android colors color-picker


【解决方案1】:

您需要使用Color Picker Collection。

实施:

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 详细说明什么?
  • 我也有与上述相同的要求。你所说的图书馆符合我的要求。你能帮我使用图书馆吗?
  • 这将是一个很大的帮助......你也可以检查我当前的问题,这将给出适当的场景
猜你喜欢
  • 2023-04-11
  • 2015-11-05
  • 1970-01-01
  • 2020-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-06
相关资源
最近更新 更多