I am working on android application where I am using TextView
to display the text on screens.
I am using this property for the TextView
to set the size of the text android:textAppearance="?android:attr/textAppearanceMedium"
.
Do I need to set the size of that text also or it does automatically manage by Android OS ?
Thanks in advance.
TextAppearance allows you to define text-specific styling while leaving a View 's style available for other uses. Note, however, that if you define any text attributes directly on the View or in a style, those values would override the TextAppearance values.
Not the attribute of TextView tag does not allow together editing.
Yes, the resizing is done automatically in the background.
While using attributes like android:textAppearance
it directly uses the predefined specific sp values for the textSize as:
android:textAppearance="?android:textAppearanceSmall" => 14sp
android:textAppearance="?android:textAppearanceMedium" => 18sp
android:textAppearance="?android:textAppearanceLarge" => 22sp
Thus it adjusts the values automatically based on the screen density and the user's preference in such a way that it seems equal on all the devices say for example formula for dp values:
px = dp * (dpi/160)
The similar case is for the sp values used only for fonts, it utilizes the same concept only difference being it may vary due to user's fontSize preference as set in settings.
I haven't used that :attr/
type as it may or may not be used and serves the same purpose because the system resource tool knows that an attribute resource is expected in this context, you do not need to explicitly state the type.
Do I need to set the size of that text also or it does automatically manage by Android OS ?
Nope, Using android:textAppearance="?android:attr/textAppearanceMedium
will make all of the text in medium size on different devices. So that means your app text on different devices will have the same size and weight.
Setting the size of each text would require calculation to be able to achieve same size and weight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With