Here is how to do it
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
puzzleView = new PuzzleView(this);
setContentView(puzzleView);
puzzleView.requestFocus();
}
In the puzzle view, onSizeChanged can be implemented to get to know about the activity size changes.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
canvasHeight = Math.min(w,h);
canvasWidth = canvasHeight;
width = canvasWidth / 9f;
height = canvasHeight / 9f;
getRect(selX, selY, selRect);
Log.d(TAG, "onSizeChanged: width " + width + ", height " + height);
super.onSizeChanged(w, h, oldw, oldh);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
puzzleView = new PuzzleView(this);
setContentView(puzzleView);
puzzleView.requestFocus();
}
In the puzzle view, onSizeChanged can be implemented to get to know about the activity size changes.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
canvasHeight = Math.min(w,h);
canvasWidth = canvasHeight;
width = canvasWidth / 9f;
height = canvasHeight / 9f;
getRect(selX, selY, selRect);
Log.d(TAG, "onSizeChanged: width " + width + ", height " + height);
super.onSizeChanged(w, h, oldw, oldh);
}
override the draw method if need to paint something
@Override
protected void onDraw(Canvas canvas) {
}
No comments:
Post a Comment