Device settings independent font size

前端 未结 3 1441
南旧
南旧 2021-01-21 04:11

While developing my app I realised if someone changes device font size from normal, my application font sizes change too and it destroys some of the visuals I designed. So I wan

3条回答
  •  不思量自难忘°
    2021-01-21 05:04

    Google recommends keeping your font sizes set with SP so that the UI settings will modify the font sizes within your application. Are you using SP?

    I believe that using DP or PX or something else will cure your issue. Keep in mind that this is not recommended for Accessibility purposes.

    For a complete list of possible text size types, see http://developer.android.com/reference/android/util/TypedValue.html

    Here they are:

    COMPLEX_UNIT_DIP - TYPE_DIMENSION complex unit: Value is Device Independent Pixels.
    COMPLEX_UNIT_IN  - TYPE_DIMENSION complex unit: Value is in inches.
    COMPLEX_UNIT_MM  - TYPE_DIMENSION complex unit: Value is in millimeters.
    COMPLEX_UNIT_PT  - TYPE_DIMENSION complex unit: Value is in points.
    COMPLEX_UNIT_PX  - TYPE_DIMENSION complex unit: Value is raw pixels.
    COMPLEX_UNIT_SP  - TYPE_DIMENSION complex unit: Value is a scaled pixel.
    

    Also: Note that not all of these options are available from an xml file and that some of these settings may only be used programmatically (at least that's what I recall).

提交回复
热议问题