自定义View唤醒屏幕显示异常
自定义View唤醒屏幕显示异常:关闭View硬件加速
硬件加速:默认硬件加速开启
硬件加速设置
Application
<application
android:hardwareAccelerated="false"
...>
</application>
Activity
<application android:hardwareAccelerated="true">
<activity ... />
<activity
android:hardwareAccelerated="false" />
</application>
Window
getWindow().setFlags( WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
View
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
两种获取是否支持硬件加速的方式
View.isHardwareAccelerated()//returns true if the View is attached to a hardware accelerated window.Canvas.isHardwareAccelerated()//returns true if the Canvas is hardware accelerated
Canvas不支持硬件加速的二维绘图接口:
- clipPath() - clipRegion() - drawPicture() - drawPosText() - drawTextOnPath() - drawVertices()
Paint不支持硬件加速的接口:
- setLinearText() - setMaskFilter() - setRasterizer()