Skip to content

Creting Completely custom Views

rutura edited this page Apr 16, 2017 · 1 revision
  • Key overides:
	@Override
    protected void onMeasure(int widthMeasureSpec,
                             int heightMeasureSpec) {
	//Compute the correct dimenstions based on measurement constraints
	//and call setMeasuredDimension with them.Details in the custom view class.
	...
	//MUST call this method with the measured values!
        setMeasuredDimension(width, height);
    }
    
    @Override
    protected void onSizeChanged(int w, int h,
                                 int oldw, int oldh) {
		//Reset your drawn shapes if the size of the view changes.
        ...
    }
	
    @Override
    protected void onDraw(Canvas canvas) {
	//Draw your shapes in here
	
    }
Clone this wiki locally