Jak narysować gładki / dithered gradient na płótnie w Androidzie
Kilka odpowiedzi wspomina o używaniu GradientDrawable.setDither (true), aby rysować płynne gradienty w Androidzie. To nie ma żadnego wpływu w moim kodzie. Jakiś pomysł, co muszę zmienić, aby uzyskać dobrze wyglądający gradient w mojej live wallpaper?
GradientDrawable gradient = new GradientDrawable(Orientation.TL_BR, colors);
gradient.setGradientType(GradientDrawable.RADIAL_GRADIENT);
gradient.setGradientRadius(canvas.getWidth() * 2);
gradient.setDither(true);
gradient.setGradientCenter(-0.1f, -0.1f);
gradient.setBounds(cb);
gradient.draw(canvas);
31
Author: Pointer Null, 2010-05-30
1 answers
Widzę, że masz płótno do pracy. Oto jedna opcja.
private Bitmap makeRadGrad() {
RadialGradient gradient = new RadialGradient(200, 200, 200, 0xFFFFFFFF,
0xFF000000, android.graphics.Shader.TileMode.CLAMP);
Paint p = new Paint();
p.setDither(true);
p.setShader(gradient);
Bitmap bitmap = Bitmap.createBitmap(400, 400, Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
c.drawCircle(200, 200, 200, p);
return bitmap;
}
Wynik:
71
Author: Eric Schlenz,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-13 08:04:08
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-13 08:04:08