How to properly set line height for Android?

前端 未结 6 1372
礼貌的吻别
礼貌的吻别 2020-12-13 03:37

I am a UX architect working with a team of Android developers that are mostly junior. We are having issues properly setting line height in Android.

We are using the

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 04:12

    I'll explain this from Android Developer perspective.

    Line height usually means text size + "padding" top/bottom.

    So, if your designer write line height 19sp and text size 15sp, it means you need to have extra padding 4sp.

    19sp - 15sp = 4sp.

    To implement it in your layout, use lineSpacingExtra attribute.

    
    

    Another way to achieve line height is using scale. For example, 1.2. It means, the spacing is 120% of the text size.

    In example above, the line height is 19sp and the text size is 15sp. If we translate it into scale, it become.

    19/15 = 1.26

    To implement it in your layout, use the lineSpacingMultiplier attribute.

    
    

提交回复
热议问题