Dynamic Text size change according to tablet

前端 未结 4 1645
独厮守ぢ
独厮守ぢ 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:38

    I was Having Same Problem but what i realized sp/db are not efficient for dealing with this kind of problem, I handled my alignment and font size related stuff programtically.

    here are the steps, how i handled this problem.

    • Calculate Screen Width and Height of Your device
    • Use Set TextView.setTextSize(unit, size), where the unit parameter is TypedValue.COMPLEX_UNIT_PX and the size parameter is percent of the total width of your screen. Normally, for me, .5% of total width for font is suitable. You can experiment by trying other total width percentages, such as 0.4% or 0.3%.

    This way your font size will be always suitable for each and every text/screen size.

提交回复
热议问题