hasanghaforian
hasanghaforian

Reputation: 14022

using "sp" unit instead of "dp" unit for determining dimensions of view

Usually sp is used for setting text size but is it a bad practice to use that for setting dimensions of view in layout? I did not see any warning on this line of .xml file:

android:layout_height="20sp"

This question indirectly follows my previous question.

Upvotes: 1

Views: 210

Answers (1)

Gavin Wright
Gavin Wright

Reputation: 3212

Using sp for View dimensions will literally scale the entire UI based on the user's font size preference. If that's what you want, go for it. But I would imagine you'll run into difficulties making your Views look good at all font size preference levels. You'll design your UI for one font size and then when you switch to another your Views will look dramatically different.

Upvotes: 1

Related Questions