Android ShapeDrawable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ShapeDrawable class.

This code example shows how to use the following methods: getPaint, setIntrinsicHeight, setIntrinsicWidth
This code example shows how to use the following methods: getPaint
        } 
 
        private ShapeHolder addBall(float x, float y) {
            OvalShape circle = new OvalShape();
            circle.resize(50f * mDensity, 50f * mDensity);
            ShapeDrawable drawable = new ShapeDrawable(circle);
            ShapeHolder shapeHolder = new ShapeHolder(drawable);
            shapeHolder.setX(x - 25f);
            shapeHolder.setY(y - 25f);
            int red = (int)(100 + Math.random() * 155);
            int green = (int)(100 + Math.random() * 155);
            int blue = (int)(100 + Math.random() * 155);
            int color = 0xff000000 | red << 16 | green << 8 | blue;
            Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
            int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
            RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
                    50f, color, darkColor, Shader.TileMode.CLAMP);
            paint.setShader(gradient);
            shapeHolder.setPaint(paint);
            balls.add(shapeHolder);
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getPaint
 
@RunWith(TestRunners.WithDefaults.class) 
public class ShapeDrawableTest { 
    @Test 
    public void getPaint_ShouldReturnTheSamePaint() throws Exception { 
        ShapeDrawable shapeDrawable = new ShapeDrawable();
        Paint paint = shapeDrawable.getPaint();
        assertNotNull(paint);
        assertThat(shapeDrawable.getPaint()).isSameAs(paint);
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setIntrinsicHeight, setIntrinsicWidth
This code example shows how to use the following methods: setShape, resize
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android ShapeDrawable Questions & Answers:

See Code Examples for Android ShapeDrawable Methods: