Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import android.content.Context;
  2. import android.graphics.Canvas;
  3. import android.graphics.Color;
  4. import android.graphics.Paint;
  5. import android.util.AttributeSet;
  6. import android.view.View;
  7.  
  8. public class AimView extends View {
  9.  
  10.     private Paint mPaint;
  11.  
  12.     public AimView(Context context, AttributeSet attrs) {
  13.         super(context, attrs);
  14.         init();
  15.     }
  16.  
  17.     public AimView(Context context) {
  18.         super(context);
  19.         init();
  20.     }
  21.  
  22.     private void init(){
  23.         mPaint = new Paint();
  24.         mPaint.setColor(Color.BLACK);
  25.         mPaint.setStyle(Paint.Style.STROKE);
  26.         mPaint.setStrokeWidth(10);
  27.     }
  28.  
  29.     @Override
  30.     protected void onDraw(Canvas canvas) {
  31.         int w = getWidth();
  32.         int h = getHeight();
  33.  
  34.         float left   = w*3.f/10;
  35.         float top    = h*3.f/10;
  36.         float right  = w*7.f/10;
  37.         float bottom = h*7.f/10;
  38.        
  39.         canvas.drawRect(left, top, right, bottom, mPaint); //todo smth like this
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement