m13984458297
A_mnesia
采纳率66.7%
2017-11-30 10:50

android 7.0以上系统把webview内容生成长图异常

5
已采纳

Android开发 想把webview的内容生成长图保存本地,7.0以上系统只能截取第一屏的内容生成长图,超出第一屏的显示
空白,7.0以下的正常生成,生成代码如下,哪位大神能指点一二吗 ,谢谢了,代码:
public Bitmap viewShot(final View view) {
if (view == null)
return null;
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
view.measure(measureSpec, measureSpec);
if (view.getMeasuredWidth() <= 0 || view.getMeasuredHeight() <= 0) {
return null;
}
Bitmap bm;
try {
bm = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError e) {
System.gc();
try {
bm = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError ee) {
return null;
}
}
Canvas bigCanvas = new Canvas(bm);
Paint paint = new Paint();
int iHeight = bm.getHeight();
bigCanvas.drawBitmap(bm, 0, iHeight, paint);
view.draw(bigCanvas);
return bm;
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • m13984458297 A_mnesia 4年前
    点赞 评论 复制链接分享
  • weixin_41236902 weixin_41236902 4年前

    说明是你的strus拦截器的配置出了问题

    点赞 评论 复制链接分享
  • qq_41232840 qq_41232840 4年前

    sfegerghrhrh

    点赞 评论 复制链接分享