错误日志
03-31 18:41:36.523 2715-2715/demo.turing.com.materialdesignwidget W/EGL_emulation: eglSurfaceAttrib not implemented 03-31 18:41:36.527 2715-2715/demo.turing.com.materialdesignwidget E/HardwareRenderer: An error has occurred while drawing: java.lang.IllegalStateException: The display list is not valid. at android.view.GLES20DisplayList.getNativeDisplayList(GLES20DisplayList.java:49) at android.view.GLES20Canvas.drawDisplayList(GLES20Canvas.java:420) at android.view.HardwareRenderer$GlRenderer.drawDisplayList(HardwareRenderer.java:1646) at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1469) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2405) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2277) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1907) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1024) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5694) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
情景重新
我再编写一个RecyclerView的页面时,数据加载完成之后,点击进入Activity时,很卡并且无法上下滑动,查看日志发现如上信息,根据日志 HardwareRenderer….大致可以猜测出是硬件加速造成的,我使用的是模拟器,可能是对硬件加速的支持不好..
解决方法
在清单文件中对应的发生崩溃的Activity中加入
android:hardwareAccelerated=”false”
如下所示
<activity android:name=".recyclerView.RecyclerViewAct" android:hardwareAccelerated="false" />
重新运行,问题解决。