Android7.0 自定义view开启硬件加速报错
来源:互联网 发布:java socket链接不上 编辑:程序博客网 时间:2024/05/20 18:19
Android7.0 开启硬件加速后部分应用运行出错。
canvas绘制从网络获取图片报错
出现异常:
5-10 02:07:53.362 1675-1758/system_process W/WindowAnimator: Failed to dispatch window animation state change.
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.view.IWindow$Stub$Proxy.onAnimationStopped(IWindow.java:534)
at com.android.server.wm.WindowAnimator.updateWindowsLocked(WindowAnimator.java:286)
at com.android.server.wm.WindowAnimator.animateLocked(WindowAnimator.java:678)
at com.android.server.wm.WindowAnimator.-wrap0(WindowAnimator.java)
关闭硬件加速则运行正常。
原因在这里
http://developer.android.com/guide/topics/graphics/hardware-accel.html
Hardware Acceleration
Beginning in Android 3.0 (API level 11), the Android 2D rendering pipeline is designed to better support hardware acceleration.
从Android 3.0(API Level 11)开始,Android的2D渲染管线可以更好的支持硬件加速。硬件加速使用GPU进行View上的绘制操作。
... ...
Unsupported Drawing Operations
不支持的绘图方法:- Canvas
clipPath()
clipRegion()
drawPicture()
drawTextOnPath()
drawVertices()
- Paint
setLinearText()
setMaskFilter()
setRasterizer()
- Xfermodes
AvoidXfermode
PixelXorXfermode
问题找到,
解决方法:
有4种控件硬件加速的方法。
1 Application level
In your Android manifest file, add the following attribute to the <application>
tag to enable hardware acceleration for your entire application:
在应用程序AndroidManifest.xml文件中,为application标签添加如下的属性即可为整个应用程序true开启、false关闭硬件加速
<application android:hardwareAccelerated="false" ...>
2 Activity level
<application android:hardwareAccelerated="true"> <activity ... /> <activity android:hardwareAccelerated="false" /></application>
3 Window level
If you need even more fine-grained control, you can enable hardware acceleration for a given window with the following code:
getWindow().setFlags( WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
Note: You currently cannot disable hardware acceleration at the window level.
4 View level
You can disable hardware acceleration for an individual view at runtime with the following code:
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
- Android7.0 自定义view开启硬件加速报错
- Android自定义view之硬件加速
- android7.0 Jack编译器报错解决
- Android7.1报错
- HenCoder Android 自定义 View 1-8 硬件加速
- AlertDialog自定义view报错
- Android ListFragment自定义view报错解决方案
- 自定义View的XML报错问题
- 问题: 自定义view MarginLayoutParams报错
- Android7.0 快速开启分屏功能
- 开启Android7.0探索之旅
- [Android7.0]开启NFC的流程分析
- 解决android7.0报错:android.os.FileUriExposedException
- Android7.0 添加自定义SystemService
- DirectX 开启硬件加速
- chrome如何开启硬件加速?
- win2003开启硬件加速
- 开启与关闭硬件加速
- PHP——数据库(删除)
- java类加载器加载机制解析
- Android GC
- Windows多线程同步
- Java多线程(1)
- Android7.0 自定义view开启硬件加速报错
- C++ 对象的内存布局(上)
- Informatica
- Spark作业运行原理
- Android面试之2017美团面试最新
- iOS移动端WebApp的JS与Native交互(JS与OC)
- c语音动态内存分配,内存重新分配,内存释放,指针运算
- 10个值得深思的 PHP 面试问题
- ajax往服务端发送checkbox的数组方式,服务端采用springMVC架构