• 12

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

Several answers mention to use GradientDrawable.setDither(true) to draw smooth gradients in Android. That has no effect in my code. Any idea what I have to change to get a well looking gradient in my live wallpaper?

GradientDrawable gradient = new GradientDrawable(Orientation.TL_BR, colors);
gradient.setGradientRadius(canvas.getWidth() * 2);
gradient.setGradientCenter(-0.1f, -0.1f);

Seeing as you have a Canvas to work with. Here is one option.

private Bitmap makeRadGrad() {
    RadialGradient gradient = new RadialGradient(200, 200, 200, 0xFFFFFFFF,
            0xFF000000, android.graphics.Shader.TileMode.CLAMP);
    Paint p = new Paint();

    Bitmap bitmap = Bitmap.createBitmap(400, 400, Config.ARGB_8888);
    Canvas c = new Canvas(bitmap);
    c.drawCircle(200, 200, 200, p);

    return bitmap;



  • 78
Reply Report
      • 1
    • What I do not fully understand is why do you have to define coordinates (200, 200, 200) two times. What should I do to dynamically adjust the position and most importantly SIZE of the gradient in onDraw() method ?
      • 1
    • The first coordinates define the size of the gradient, the second set of coordinates describes the size of the circle containing the gradient. If the coordinates are not the same the gradient would not fill the circle or would get cut off by the circle bounds.