自定义view界面提示The application may be doing too much work on its main thread.

    xiaoxiao2021-12-15  29

    

    界面在activity显示完:提示The application may be doing too much work on its main thread.

    且刷新界面也会提示:The application may be doing too much work on its main thread.刷新个20遍,界面就会重启。

    代码注释,发现是自己自定义view在

    invalidate()

    时候会出现上诉问题。切入自定义view的draw(),发现是

    Typeface custom_font = Typeface.createFromAsset(mContext.getAssets(),"fonts/advent_regular.ttf")

    ;这句初始化字体的

    的问题。把初始化字体这句放在

    public 自定义View_name(Context context, AttributeSet attrs) {

     custom_font = Typeface.createFromAsset(mContext.getAssets(),"fonts/advent_regular.ttf")

    }不放在draw就可以。

    问题解决。

    转载请注明原文地址: https://ju.6miu.com/read-1000210.html

    最新回复(0)