How to possible page curl with textView in android

2019-04-12 00:41发布

问题:

I found the good harism's project that allows a beautiful paging effect like following link https://github.com/harism/android_page_curl. But works only images,My requirement is to use editText through write data and also save So,kindly give me Suggestion or code. I also visit bellow given link: Android page curl by harism , adding TextView caused and exception : But above link use textView not Edit Text.

回答1:

it is so simple. Just replace the loadBitmap method in the CurlActivity with the below method,

private Bitmap loadBitmap(int width, int height, int index) {
    Bitmap txtBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    String text1 = yourPagesStringArray[index];
    Canvas c = new Canvas(txtBitmap);
    TextView tv = new TextView(getApplicationContext());
    tv.setText(text1);
    tv.setTextColor(0xa00050ff);
    tv.setTextSize(15);
    tv.setLinksClickable(true);
    tv.setLineSpacing(2, 2);
    tv.layout(0, 0, getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels);
    tv.draw(c);

    c.drawBitmap(txtBitmap, 0, 0, null);

    return txtBitmap;
}