Rounded rect RectF Android example

RectF, drawRoundRect(),

public class MainActivity extends Activity {
 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}
 
	private static class SampleView extends View {
 
		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);
 
		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
 
			canvas.drawColor(Color.GREEN);
 
           Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
           Canvas c = new Canvas(b);
           RectF rectF = new RectF();
           rectF.set(5,5,150,150);
           c.drawRoundRect(rectF, 10, 10, paint);
 
            paint.setColor(Color.RED);
 
           canvas.drawBitmap(b, 10,10, paint);
		}
 
	}
}

draw-rounded-rect-android

This entry was posted in Android Examples Code and tagged , . Bookmark the permalink.


Comments are closed.

16,406 views