Font size of TextView in Android application changes on changing font size from native settings

前端 未结 14 2126
抹茶落季
抹茶落季 2020-12-04 07:47

I want to specify my own text size in my application, but I am having a problem doing this.

When I change the font size in the device settings, the font size of my

14条回答
  •  鱼传尺愫
    2020-12-04 08:37

    Use the dimension type of resources like you use string resources (DOCS).

    In your dimens.xml file, declare your dimension variables:

    
    
      25dp
      150dp
      30dp
      16sp
    
    

    Then you can use these values like this:

    
    

    You can declare different dimens.xml files for different types of screens. Doing this will guarantee the desired look of your app on different devices.

    When you don't specify android:textSize the system uses the default values.

提交回复
热议问题