Android RoundRectShape - 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 RoundRectShape class.

This code example shows how to use the following methods:
	private ShapeDrawable getDefaultBackground() {
		 
		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;
6
CodeRank
This code example shows how to use the following methods:
	private ShapeDrawable getDefaultBackground() {
		 
		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;
6
CodeRank
This code example shows how to use the following methods:
        return drawable;
    } 
 
    Shape getDrawableShape() {
        final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
        return new RoundRectShape(roundedCorners, null, null);
    } 
 
    /** 
     * Convert a AnimationDrawable for use as a barberpole animation. 
     * Each frame of the animation is wrapped in a ClipDrawable and 
     * given a tiling BitmapShader. 
     */ 
    private Drawable tileifyIndeterminate(Drawable drawable) {
        if (drawable instanceof AnimationDrawable) {
            AnimationDrawable background = (AnimationDrawable) drawable;
            final int N = background.getNumberOfFrames();
            AnimationDrawable newBg = new AnimationDrawable();
            newBg.setOneShot(background.isOneShot());
 
5
CodeRank
This code example shows how to use the following methods:
		int density20 = (int) (20 * mDensity);
		int density10 = (int) (10 * mDensity);
		float[] outerRadii = new float[] { 0, 0, density20, density20,
				density20, density20, 0, 0 };
		ShapeDrawable leftBg = new ShapeDrawable(new RoundRectShape(outerRadii,
				null, null)); 
		leftBg.setBounds(0, 0, (int) (70 * mDensity), (int) (35 * mDensity));
		leftBg.getPaint().setColor(0x55000000);
 
		float[] outerRadiiNone = new float[] { density10, density10, density10,
				density10, density10, density10, density10, density10 };
		ShapeDrawable noneBg = new ShapeDrawable(new RoundRectShape(
				outerRadiiNone, null, null));
		noneBg.setBounds(0, 0, (int) (70 * mDensity), (int) (35 * mDensity));
		noneBg.getPaint().setColor(0x55000000);
 
		float[] outerRadiiRight = new float[] { density20, density20, 0, 0, 0,
				0, density20, density20 };
		ShapeDrawable rightBg = new ShapeDrawable(new RoundRectShape(
				outerRadiiRight, null, null));
4
CodeRank
This code example shows how to use the following methods:
           layers.add(borderLayer);
       } 
        /** define bottom margin**/ 
       /**if color of the face  is indicated **/ 
        if(this.colorFace!=0){
            RoundRectShape rs = new RoundRectShape(cornersRound, null, null);
            ShapeDrawable solidBackgroundLayer=new ShapeDrawable(rs);
            solidBackgroundLayer.getPaint().setColor(this.colorFace);
            layers.add(solidBackgroundLayer);
        } 
 
        /**if there is an image icon **/ 
        if(this.imageSrc!=null){
            DisplayMetrics metrics = new DisplayMetrics();
            WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
            wm.getDefaultDisplay().getMetrics(metrics);
            /**create bitmap drawable that ll be show when icon is pressed**/ 
            bitmap = new BitmapDrawable(getResources(),this.imageSrc);
            bitmap.setGravity(Gravity.CENTER);
            bitmap.setTargetDensity(metrics);
4
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
		else if (randomNumber == 1) 
		{  
			float[] roundedCorner = new float[] { r.nextInt(400), r.nextInt(400), r.nextInt(400), r.nextInt(400), 
					r.nextInt(400), r.nextInt(400), r.nextInt(400), r.nextInt(400) };
			 
			mDrawable = new ShapeDrawable(new RoundRectShape(roundedCorner, null, null));
		} 
		else if (randomNumber == 2)
		{ 
			// rectangle figure 
			mDrawable = new ShapeDrawable(new RectShape());
		} 
		else if (randomNumber == 3)
		{ 
			// round figure 
			mDrawable = new ShapeDrawable(new OvalShape());
		} 
		 
		mDrawable.getPaint().setColor(intColor.chooseRandomColor());
		mDrawable.setBounds(x, y, x + width, y + height);
4
CodeRank
This code example shows how to use the following methods:
 
            mDrawables = new ShapeDrawable[7];
            mDrawables[0] = new ShapeDrawable(new RectShape());
            mDrawables[1] = new ShapeDrawable(new OvalShape());
            mDrawables[2] = new ShapeDrawable(new RoundRectShape(outerR, null,
                                                                 null)); 
            mDrawables[3] = new ShapeDrawable(new RoundRectShape(outerR, inset,
                                                                 null)); 
            mDrawables[4] = new ShapeDrawable(new RoundRectShape(outerR, inset,
                                                                 innerR));
            mDrawables[5] = new ShapeDrawable(new PathShape(path, 100, 100));
            mDrawables[6] = new MyShapeDrawable(new ArcShape(45, -270));
 
            mDrawables[0].getPaint().setColor(0xFFFF0000);
            mDrawables[1].getPaint().setColor(0xFF00FF00);
            mDrawables[2].getPaint().setColor(0xFF0000FF);
            mDrawables[3].getPaint().setShader(makeSweep());
            mDrawables[4].getPaint().setShader(makeLinear());
            mDrawables[5].getPaint().setShader(makeTiling());
            mDrawables[6].getPaint().setColor(0x88FF8844);
4
CodeRank
This code example shows how to use the following methods:
    	else 
    		color = "#654321";
 
	    // Define a shape with rounded corners 
	    final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
	    ShapeDrawable pgDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));
	    //ShapeDrawable pgDrawable = new ShapeDrawable(new RectShape()); 
	    // Sets the progressBar color 
	    pgDrawable.getPaint().setColor(Color.parseColor(color));
 
	    // Adds the drawable to your progressBar 
	    ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
	    m_progress.setProgressDrawable(progress);
	    m_progress.setBackgroundColor(Color.GRAY);
    } 
     
    public void updateProgress(int val) {
    	m_progress.setProgress(val);
    		 
    } 
4
CodeRank
This code example shows how to use the following methods:
    	else 
    		color = "#654321";
 
	    // Define a shape with rounded corners 
	    final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
	    ShapeDrawable pgDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));
	    //ShapeDrawable pgDrawable = new ShapeDrawable(new RectShape()); 
	    // Sets the progressBar color 
	    pgDrawable.getPaint().setColor(Color.parseColor(color));
 
	    // Adds the drawable to your progressBar 
	    ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
	    m_progress.setProgressDrawable(progress);
	    m_progress.setBackgroundColor(Color.GRAY);
    } 
     
    public void updateProgress(int val) {
    	m_progress.setProgress(val);
    		 
    } 
4
CodeRank

Related Android RoundRectShape Questions & Answers:

See Code Examples for Android RoundRectShape Methods: