且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

TextView中的Andr​​oid应用程序改变字体大小从原生设置改变字体大小

更新时间:2022-02-13 08:45:10

其实,设置字体大小只影响大小在 SP 。因此,所有你需要做的 - 定义 TEXTSIZE 而不是 SP $ c。在 DP $ C>,然后设置不会改变文字大小在您的应用程序。

Actually, Settings font size affects only sizes in sp. So all You need to do - define textSize in dp instead of sp, then settings won't change text size in Your app.

下面是一个链接的文档:Dimensions

Here's a link to the documentation: Dimensions

但是请注意预期的行为是在所有的应用程序的字体尊重用户的preferences。有很多原因,用户可能需要调整字体大小,其中有些甚至可能是医疗 - 视障用户。使用 DP 而不是 SP 文本可能导致不情愿歧视你的一些应用程序的用户。

However please note that the expected behavior is that the fonts in all apps respect the user's preferences. There are many reasons a user might want to adjust the font sizes and some of them might even be medical - visually impaired users. Using dp instead of sp for text might lead to unwillingly discriminating against some of your app's users.