java - Android canvas.save() 和 canvas.restore() 使我的应用程序崩溃
问题描述
我尝试在这样的视图中显示一个画布:
protected void onPostExecute(Canvas canvas){
Rect rect = new Rect();
rect.set(0,0,nbColumns*65,nbLines*20);
View v = activity.findViewById(R.id.viewOfPDF);
int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), View.MeasureSpec.EXACTLY);
int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), View.MeasureSpec.EXACTLY);
v.measure(widthSpec, heightSpec);
v.layout(0, 0, rect.width(), rect.height());
canvas.save();
canvas.translate(rect.left, rect.top);
v.draw(canvas);
canvas.restore();
}
但是当我运行我的活动时,我的应用程序出错了。这不是例外:
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 25473 (iondestagiaires), pid 25473 (iondestagiaires)
我这样做了save()
,restore()
就在这一次。
我的观点只是一个简单的观点。
你能帮助我吗?
解决方案
单击设置-> 构建、执行、部署-> 部署-> 即时运行。
然后取消选中顶部的“启用即时运行”复选框。
推荐阅读
- selenium - 我想在 selenium 上使用多个使用 firefox 的浏览器,但我的速度变慢了
- github-actions - 从 github 容器图像摘要中检索标签和提交哈希
- bash - 获取只有显示名称的服务主体客户端 ID
- linux - Gtk+3: 插入过多时 GtkTextBuffer 更新缓慢
- python - 循环循环动态大小的python字典
- winapi - 微软更改了 WIN32_FIND_DATA 声明并添加了 3 个新属性
- python - 如何打印没有第一个方括号的列表?
- maven - 如何设置 Jenkins 管道以使用未提交到 GitHub 的 secrets.properties 文件
- docker - Docker不断重启,日志没有错误
- android - Firebase 身份验证 - 未处理的异常:[firebase_auth/admin-restricted-operation] 此操作仅限于管理员