public BasketballView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); screenWidth = wm.getDefaultDisplay().getWidth(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.drawable.training_challenge_court_medium_active, options); originWidth = options.outWidth; originHeight = options.outHeight; mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(strokeWidth); mPaint.setColor(Color.YELLOW); mOvalPath = new Path(); mRectPath = new Path(); mRectF = new RectF(); mRegion = new Region(); tempRegon = new Region(); mRegionIterator = new RegionIterator(tempRegon); mTempRect = new Rect(); mTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); //mTextPaint.setTextAlign(Paint.Align.LEFT); mTextPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28, getResources().getDisplayMetrics())); mTextPaint.setColor(Color.WHITE); }