Advertisement
Guest User

Untitled

a guest
Aug 17th, 2011
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.  
  2. public class DrawOnTop extends View{
  3.    
  4.     public DrawOnTop(Context context) {
  5.         super(context);
  6.     }
  7.  
  8.     @Override
  9.     protected void onDraw(Canvas canvas) {
  10.     // TODO Auto-generated method stub
  11.     Paint paint = new Paint();
  12.     paint.setStyle(Paint.Style.FILL);
  13.     paint.setColor(Color.BLACK);
  14.     paint.setTextSize(20);
  15.     canvas.drawText("Test Text", 20, 20, paint);
  16.  
  17.         paint.setStyle(Paint.Style.STROKE);
  18.         paint.setStrokeWidth(2);
  19.         paint.setColor(Color.RED);
  20.        
  21.         Path path = new Path();
  22.         path.moveTo(50, 50);    
  23.         path.lineTo(100, 0);
  24.        
  25.         path.lineTo(150, 50);        
  26.         path.close();
  27.        
  28.         path.offset(110, 150);
  29.         canvas.drawPath(path, paint);
  30.        
  31.        
  32.         super.onDraw(canvas);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement