1
votes

I set textSize in my TextView at 14sp in mdpi mode and I dont know what is the best size preference(sp) for textSize in ldpi, hdpi, xhdpi, and xxhdpi modes.

Is there any way to convert sp automatically to each other in ldpi, mdpi, hdpi, xhdpi, xxhdpi modes?

3
You can use dimensions with qualifiers ldpi, mdpi, etc.. declare it on differente dimens files then use @dimens/text_size, aldo, 14sp are scalable and I think it will look different on dimmensions (else it will look equals at least)Marcos Vasconcelos

3 Answers

1
votes

You can use this depedency to handle to all dp and sp : implementation 'com.intuit.sdp:sdp-android:1.0.5' and use in the xml like this:- android:padding="@dimen/_10sdp" also in the java/ kotlin file like this R.dimen._100sdp.

2
votes

You don't need to. Sp is automatically scaled to different densities. Its like dp in that way. The difference is that its also scaled by a factor in the settings the user can adjust, in order to make the text easier to read for people with sight issues.

2
votes

sp is a density-independent measurement, like dp, so there's no need to have a separate size for the other modes. The difference between dp and sp is just that sp includes a scale factor based on the user's font size preference.