Question

I'm using Ambilvarna color picker library in my project, it works fine in lower versions, but in my jelly bean device the bottom black shade is not rendering properly. I searched for a solution but this type of issue is occurring only in honeycomb devices, because of hardware acceleration, but that got solved already. The same fix doesn't work for me though. Any ideas?

Était-ce utile?

La solution

i had the same problem with tat library but i made a little change to onDraw method of its AmbilWarnaKotak class after tat it works fine

@Override 
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int w = canvas.getWidth(), h = canvas.getHeight();

    Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types

    Bitmap bmp = Bitmap.createBitmap(w, h, conf); 
    Canvas canvas2=new Canvas(bmp);
    if (paint == null) {
        paint = new Paint();
        luar = new LinearGradient(0.f, 0.f, 0.f, this.getMeasuredHeight(), 0xffffffff, 0xff000000, TileMode.CLAMP);
    }

    int rgb = Color.HSVToColor(color);
    Shader dalam = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, 0xffffffff, rgb, TileMode.CLAMP);
    ComposeShader shader = new ComposeShader(luar, dalam, PorterDuff.Mode.MULTIPLY);
    paint.setAntiAlias(true);
    paint.setShader(shader);
    canvas2.drawRect(0.f, 0.f, this.getMeasuredWidth(), this.getMeasuredHeight(), paint);
    canvas.drawBitmap(bmp, 0, 0, paint);

}

enter image description here

Autres conseils

I have made a fork of android-color-picker where DialogFragment is used and is re-created on configuration change. It is also better adjusted for bigger screens and targets Android API 18 level. Here's the link: https://github.com/lomza/android-color-picker ;)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top