Can you give me a solution to create curl page with 2 pages (like book) using this here , Actually, I've try code Harism here , but its getting hard to implement it when my content is dynamic not static. Any solution please?
2 Answers
Page curl animation created by harism animates three pages.If you can control setting text to them you can achieve what you want. :)

- 1,873
- 1
- 18
- 33
to show two pages side by side you need to set the viewmode to 2.
mCurlView.setviewMode(2);
here are a couple of solutions for dynamically setting your bitmaps, the simplest but not maybe the prettiest is to set the drawing cache to enabled and then make a bitmap from there...
RootView.setDrawingCacheEnabled(true);
Bitmap bitmap = RootView.getDrawingCache();
RootView.setDrawingCacheEnabled(false);
i had trouble getting the transition between the curlview and RootView to work smoothly...
For my own app what i did was to use Canvas to draw text to bitmaps and save them to files for use by the PageProvider class
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.rgb(61, 61, 61));
paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);
float yOffset = UPPERPADDING;
Rect bounds = new Rect();
paint.getTextBounds(mText, 0, mText.length(), bounds);
String path = Environment.getExternalStorageDirectory().toString();
File directory = new File (path +"/mydir");
if (!directory.exists()) directory.mkdir();
File filename = new File(path, "/mydir/"+DynamicFileName+".png");
if (!filename.exists()) filename.createNewFile();
canvas.drawText(line, bounds.left + PADDING, yOffset, paint);
FileOutputStream out = new FileOutputStream(filename);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
you should note this pseudocode leaves some issues like multiline text, line spacing, try and catch, etc...
You should also note that you can increase or decrease the number of animation pages by either dynamically or statically setting the page count in the PageProvider class...
personally i used a List arraylist to hold my bitmaps so i did this...
@Override
public int getPageCount() {
if (maps.isEmpty()){
return 1;
}else{
return maps.size()+1;}
}
and in the loadBitmap method i set the bitmaps like this
b = Bitmap.createBitmap(660, 660, Bitmap.Config.ARGB_8888);
c = new Canvas(b);
d = new BitmapDrawable(getResources(), maps.get(index));
to load maps on the front and back pages of the CurlView in the updatePage method you need to set the front and back of each page to your dynamic maps, for example:
Bitmap front = loadBitmap(width, height, FrontIndex);
Bitmap back = loadBitmap(width, height, BackIndex);
page.setBitmap(front, CurlPage.SIDE_FRONT);
page.setBitmap(back, Curlpage.SIDE_BACK);

- 16
- 3