Dynamic Text size change according to tablet

前端 未结 4 1632
独厮守ぢ
独厮守ぢ 2020-12-14 03:51

With all effort,I finally reached to the end of my first app in android. And thanks to all. But after coming to end, I realized one thing that my app text size is common in

4条回答
  •  自闭症患者
    2020-12-14 04:47

    After checking some resources I finally came up with the following solution: Within the layout-xml I define the size of the button-text with a dimension declaration:

    android:textSize="@dimen/campaign_textfontsize"
    

    I created a dimens.xml in the "/values"-subdirectory with the corresponding value

    
    
        18dp
    
    

    then I created a second values-folder "/values-sw720dp" and copied the old dimens.xml into it. In this dimens.xml I adapted the fontsize value:

    
    
        24dp
    
    

    Based on the current screensize android selects the proper dimens-value. So without any code, font is adapted to the display- (and display related button-) size.

    Hope this helps...

提交回复
热议问题