android - 如何在 android 中使用 textView 进行页面 curl ?

标签 android paging android-edittext

我找到了一个很好的 harism 项目,它允许像下面的链接一样漂亮的分页效果 https://github.com/harism/android_page_curl . 但只适用于图像,我的要求是通过写入数据使用 editText 并保存 所以,请给我建议或代码。 我还访问了下面给出的链接: Android page curl by harism , adding TextView caused and exception : 但是上面的链接使用 textView 而不是 Edit Text。

最佳答案

就是这么简单。只需将 CurlActivity 中的 loadBitmap 方法替换为以下方法即可,

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;
}

关于android - 如何在 android 中使用 textView 进行页面 curl ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9990855/

相关文章:

java - 我可以使用 objectify 中的键更快地加载我的实体吗?

android - 如何从硬盘复制图片到安卓模拟器的sd卡?

linux - 每个进程的虚拟内存统计

linux - Linux 内核能否为自己的缓冲区使用可分页(可交换)内存?

android - 设置 Android 对话框位置

android - 如何通过wifi查找设备的IP地址?

cocoa-touch - UIScrollView 在模态视图 Controller 的动画演示中滚动到不同的位置

java - 基于编辑文本输入的微调器值

android - 如何在android中使用整数验证edittext?

java - 取消分配 EditText 值