Android resource qualifiers for Huge/Small fonts (accessibility)

一曲冷凌霜 提交于 2019-12-11 10:36:02

问题


I have searched the documentation and have not found an answer so here we go:

Does Android have a resource qualifier to select between different resources when accessibility options are used? Like when the user sets font size to Huge.

I would like use different dimensions on some views when dealing with Huge/Small fonts.

Thanks in advance!


回答1:


No, there is no resource qualifier for font scale. I assume you're aware of the sp unit for specifying text size. I would suggest either -

  1. Make your layouts more flexible and sized based on their contents.
  2. You can use getResources().getConfiguration().fontScale to determine the scale at runtime, and select or adjust your layout(s) accordingly.
  3. This may cause more harm than good, and the docs explicitly say not to do this, but you could try using sp rather than dp for your various layout parameters as well.


来源:https://stackoverflow.com/questions/27364176/android-resource-qualifiers-for-huge-small-fonts-accessibility

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