Hardware Acceleration——硬件加速
以下来自google:
Beginning in Android 3.0 (API level 11), the Android 2D rendering pipeline supports hardware acceleration, meaning that all drawing operations that are performed on a View's canvas use the GPU. Because of the increased resources required to enable hardware acceleration, your app will consume more RAM.
If your application performs custom drawing, test your application on actual hardware devices with hardware acceleration turned on to find any problems. The Unsupported drawing operations section describes known issues with hardware acceleration and how to work around them.
大体意思是android自3.0引入了硬件加速, Android的2D渲染支持硬件加速,即使用GPU进行绘图,旨在得到更加平滑的动画更加平滑滚动,但是会消耗较大的内存,从API 14往上都是默认开启的,但是硬件加速并不能完善的支持所有的绘图,通常表现为内容不可见,异常或渲染错误,如果出现这样的错需要自己去关闭掉。也可以选择在多个级别启用或禁用硬件加速。
我的平台是在一个退出dialog的出现时出现闪花屏抖动现象,在关掉了当前activity的硬件加速之后,就好了。
可以从四个级别层次启用或禁止:
<application android:icon="@drawable/ic_launcher_settings" android:hardwareAccelerated="true" ...> </application>
<application android:hardwareAccelerated="true"> <activity android:hardwareAccelerated="false" /> </activity> </application>
getWindow().setFlags( WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
目前在Window层面还不能禁止加速.
myView.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
View.isHardwareAccelerated():如果View附加到一个硬加速的window上就返回true. Canvas.isHardwareAccelerated():如果Canvas被硬加速了就返回true.