how to prevent system font-size changing effects to android application?

后端 未结 8 2202
执笔经年
执笔经年 2020-11-27 03:49

I recently finished developing my android application. I used sp (Scaled pixels) for all textSize. The problem is when i adjusted the system font-size, my application\'s fon

8条回答
  •  渐次进展
    2020-11-27 04:05

    If you require your text to remain the same size, you'll have to use dp.

    To quote the documentation:

    An sp is the same base unit, but is scaled by the user's preferred text size (it’s a scale-independent pixel), so you should use this measurement unit when defining text size (but never for layout sizes).

    Emphasis mine.

    So you're seeing the expected behaviour for using sp as your units for text size.

    I don't understand what you mean about using dp taking too long to maintain your app - as far as I can tell, it'll exactly be the same amount of effort? (perhaps less, though it'll likely make it less usable for users with poor eyesight)

提交回复
热议问题