美文网首页
自定义View唤醒屏幕显示异常

自定义View唤醒屏幕显示异常

作者: pure粹 | 来源:发表于2019-03-01 12:14 被阅读0次

自定义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() 


相关文章

网友评论

      本文标题:自定义View唤醒屏幕显示异常

      本文链接:https://www.haomeiwen.com/subject/ptqduqtx.html