Answer the question
In order to leave comments, you need to log in
Why does getDimension() return 1.5 times the value specified in dimens.xml?
I have a dimens.xml resource file with content like this (for testing purposes):
<resources>
<dimen name="tab_padding">16dp</dimen>
<dimen name="title_text_size">20sp</dimen>
<dimen name="row_text_size">17sp</dimen>
</resources>
txtView.setTextSize(getResources().getDimension(R.dimen.row_text_size));
txtView.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.row_text_size));
Answer the question
In order to leave comments, you need to log in
The documentation clearly says
developer.android.com/reference/android/content/re...
and if you google the first two links
stackoverflow.com/questions/6784353/inconsistency-...
stackoverflow.com/questions/14540293/get-dimension...
and if you open the source of the method, you can see how it turns out the return is pure
. To be good, it was invented to create values for different types of screens
https://developer.android.com/samples/MediaRouter/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question