-
Notifications
You must be signed in to change notification settings - Fork 12
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
}
- Relevant files :
- https://github.com/blikoon/Ubufundi/blob/master/App1.3.2/app/src/main/java/com/blikoon/app132/MainActivity.java
- https://github.com/blikoon/Ubufundi/blob/master/App1.3.2/app/src/main/java/com/blikoon/app132/CustomView.java
- https://github.com/blikoon/Ubufundi/blob/master/App1.3.2/app/src/main/res/layout/activity_main.xml