Recommendations for reducing text size

I would like to declare some dimensions to indicate some common text sizes in my application. Are there agreed standards or are best practices recommended for the various res categories? Or were there any smart solutions for dynamically basing common text sizes at run time on the current system system by default? For example, the default text size is considered plain text. Smaller size is declared for small text / descriptions, slightly larger for small headings, much larger for main headings, etc.

+4
source share
3 answers

In our code, we often set 3 or 4 steps for the size of the text so that it looks uniform, for example

<dimen name="textview_small_size">11sp</dimen>
<dimen name="textview_middle_size">13sp</dimen>
<dimen name="textview_big_0_size">21sp</dimen>
<dimen name="textview_big_1_size">30sp</dimen>

And for the interface to look perfect, you must define individual sizes in different DPIs and screen sizes, such as the values-sw800dp-large-port.

So, just set the size of the text so that it looks perfect and follows a single rule. There is no difference between the size of a set in xml and at runtime, basically it is the same thing.

+3
source

, . Android . pdf, GOOGLE IO. , dimens.xml Android. :

res/values/dimens.xml

res/values-small/dimens.xml

res/values-normal/dimens.xml

res/values-xlarge/dimens.xml

In values/dimens.xml    
<dimen name="text_size">10dp</dimen>

In values-xlarge/dimens.xml
<dimen name="text_size">20dp</dimen>
0

, , - .

, .

( ). , enter image description here

<resources>
  <dimen name="normal_100">16dp</dimen>
  <dimen name="normal_125">20dp</dimen>
  <dimen name="normal_150">24dp</dimen>
  <dimen name="normal_175">28dp</dimen>

  <dimen name="normal_200">32dp</dimen>
  <dimen name="normal_225">36dp</dimen>
  <dimen name="normal_250">40dp</dimen>
  <dimen name="normal_275">44dp</dimen>
</resources>

This greatly increases the possibility of reuse and avoids the declaration of single-use literals of one-time use, for example

<dimen name="home_screen_banner_textLeftPadding">16dp</dimen>

For a full descriptive article, see this .

Hope this helps! :)

0
source

All Articles