ShapeDrawable getPaint - top ranked examples from Open Source projects

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

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);
8
CodeRank
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);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getPaint
		 
		int r = dipToPixels(DEFAULT_CORNER_RADIUS_DIP);
		float[] outerR = new float[] {r, r, r, r, r, r, r, r};
         
		RoundRectShape rr = new RoundRectShape(outerR, null, null);
		ShapeDrawable drawable = new ShapeDrawable(rr);
		drawable.getPaint().setColor(badgeColor);
		 
		return drawable;
		 
	} 
	 
	private void applyLayoutParams() { 
		 
		FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		 
		switch (badgePosition) {
		case POSITION_TOP_LEFT:
			lp.gravity = Gravity.LEFT | Gravity.TOP;
			lp.setMargins(badgeMarginH, badgeMarginV, 0, 0);
7
CodeRank
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);
7
CodeRank
This code example shows how to use the following methods:ofInt, setBounds, getPaint
    	/* Setup shape */ 
        shape = new OvalShape();
        shape.resize(50, 50);
 
    	/* Setup drawable */ 
		myShapeDrawable = new ShapeDrawable(shape);
		myShapeDrawable.getPaint().set(paint);
		myShapeDrawable.setBounds(125, 225, 275, 375);
 
    	/* Setup view (which will draw our drawable) */ 
		final MyView myView = new MyView(this);
		setContentView(myView);
 
    	/* Setup Animator */ 
		ObjectAnimator a = ObjectAnimator.ofInt(myShapeDrawable, "alpha", 0, 100);
		a.setDuration(10000);
 
		a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        	/* Listen to the update event */ 
			@Override 
7
CodeRank
This code example shows how to use the following methods:setBounds, draw, getPaint, setShape
This code example shows how to use the following methods:getPaint
		 
		int r = dipToPixels(DEFAULT_CORNER_RADIUS_DIP);
		float[] outerR = new float[] {r, r, r, r, r, r, r, r};
         
		RoundRectShape rr = new RoundRectShape(outerR, null, null);
		ShapeDrawable drawable = new ShapeDrawable(rr);
		drawable.getPaint().setColor(badgeColor);
		 
		return drawable;
		 
	} 
	 
	private void applyLayoutParams() { 
		 
		FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		 
		switch (badgePosition) {
		case POSITION_TOP_LEFT:
			lp.gravity = Gravity.LEFT | Gravity.TOP;
			lp.setMargins(badgeMarginH, badgeMarginV, 0, 0);
7
CodeRank
This code example shows how to use the following methods:getBounds, invalidateSelf, getPaint
			mBlueText.setText(Integer.toString(blue)); 
            redSeekBar.setProgress(red); 
            greenSeekBar.setProgress(green); 
            blueSeekBar.setProgress(blue); 
			mNewBoxBackground.getPaint().setShader(getPreviewBackground(newColor, mNewBoxBackground.getBounds())); 
			mPreviousBoxBackground.getPaint().setShader(getPreviewBackground(mPreviousColor, mPreviousBoxBackground.getBounds())); 
			mNewBoxBackground.invalidateSelf(); 
			mPreviousBoxBackground.invalidateSelf(); 
			broadcastColorChange(); 
		} 
 
	}; 
 
	/** 
	 * Returns a "glossy" background using the given color and the given bounds. Currently, 
	 * the gloss is applied vertically from top to bottom. 
	 * 
	 * @param color the color to be "glossed" 
	 * @param rect the bounds of the area to be glossed 
	 * @return a {@link android.graphics.LinearGradient} to be used for the background of a color preview 
6
CodeRank
This code example shows how to use the following methods:setBounds, getPaint
 
        /* Setup Circle */ 
        shape = new OvalShape();
        shape.resize(50, 50);
 
        drawable = new ShapeDrawable(shape);
        drawable.getPaint().set(paint);
        drawable.setBounds(125, 225, 275, 375);
        drawables.add(drawable); // Add it to our list!
 
        /* Setup Rectangle */ 
        shape = new RectShape();
        shape.resize(50, 50);
 
        drawable = new ShapeDrawable(shape);
        drawable.getPaint().set(paint);
        drawable.setBounds(475, 225, 625, 375);
        drawables.add(drawable); // Add it to our list!
 
        setContentView(new MyView(this));
6
CodeRank

Related ShapeDrawable getPaint Questions & Answers:

getPaint Method Overview
Returns the Paint used to draw the shape.
See Code Examples for other Android ShapeDrawable Methods: