Font size too large to fit in cache

岁酱吖の 提交于 2019-11-27 01:35:23

Just an idea: Perhaps you can convert the font to an outline using Paint.getTextPath(...) and use this path to render the text. This should allow you to resize the path as needed.

It is really a bug in the Android OS inside the Hardware Acceleration modules. I think that the best way is to ask the system to avoid HW acceleration on TextViews that contain large size text. To do so, just add in the code:

TextView bigText = (TextView) findViewById(R.id.bigtext);
bigText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

The setLayerType method is useful, but unfortunately it is supported just for API >= 11. Developing for API = 8 or less it will become unusable.

If you can, a simple solution is disabling the hardware acceleration just for the activity that is giving you problems. I had this very problem and solved it this way:

<application
    android:...
    android:hardwareAccelerated="true" >
    <activity ...>
        ...
    </activity>

    <activity
        ...
        android:hardwareAccelerated="false">
        ...
    </activity>
</application>

This solution will disable the hardware acceleration just for the activities where you do not need it and where you aren't able to display large texts.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!