-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify current page./redraw current page. #50
Comments
First, you need to know the PageFlip needs a bitmap you passed to show on the screen, if flipping, it needs another bitmap for the next page, that means, PageFlip will at least have two bitmap to show during flipping, one is the first page - current showing page, another is the next page - waiting to show, so, when you want to change anything on current showing page, you just use the canvas to draw anything you want on this bitmap and then pass it to PageFlip to show again, here is an example for how to draw with canvas: Line 174 in adf677e
// 1. draw background bitmap
Bitmap background = LoadBitmapTask.get(mContext).getBitmap();
Rect rect = new Rect(0, 0, width, height);
mCanvas.drawBitmap(background, null, rect, p);
background.recycle();
background = null;
// 2. draw page number
int fontSize = calcFontSize(80);
p.setColor(Color.WHITE);
p.setStrokeWidth(1);
p.setAntiAlias(true);
p.setShadowLayer(5.0f, 8.0f, 8.0f, Color.BLACK);
p.setTextSize(fontSize);
String text = String.valueOf(number);
float textWidth = p.measureText(text);
float y = height - p.getTextSize() - 20;
mCanvas.drawText(text, (width - textWidth) / 2, y, p);
... After you have a new bitmap with your desired changes, then you can do like the following codes in function: Line 60 in adf677e
// draw stationary page without flipping
else if (mDrawCommand == DRAW_FULL_PAGE) {
if (!page.isFirstTextureSet()) {
drawPage(mPageNo);
page.setFirstTexture(mBitmap);
}
mPageFlip.drawPageFrame();
} |
Hi I am trying to update the text of my current page when a button is clicked.
I have the button working but I can't get the page to redraw with the new changes.
How can I redraw the current page on screen? Thank you.
The text was updated successfully, but these errors were encountered: