Reputation: 515
I'm working on an app that is (supposed to be) device-specific (theoretically always used on a Nexus 7, though it may be either version of that device). Many of the Views will contain some combination of text and graphics, positioned in ways that are meaningful. If I use "sp" to define text sizes as recommended, and the user globally changes the "text size", the text will be scaled but the graphics will not - completely destroying the visual presentation.
I want to use dp instead of hard pixel units because the different versions of the Nexus 7 have different display densities. It would also be nice if the positional relationships were maintained if, say, somebody changes their mind and the app gets run on some other display. dp handles this for graphics, but by having a different measurement unit for text it allows the overall presentation to be damaged by the user.
Is there a way to disable the scaling that is optionally applied to "sp", so that the relationships between graphics (defined with dp) and text (defined with sp) can't be corrupted? Frankly, I'd like to just define the text with dp but can't find a way using code to do so (none of the TypedValue constants seem to support it).
Thanks!
Upvotes: 0
Views: 692
Reputation: 1006614
If I use "sp" to define text sizes as recommended, and the user globally changes the "text size", the text will be scaled but the graphics will not - completely destroying the visual presentation.
User-controlled font scaling has been around for a long time in desktop GUIs, and came to prominence in Web design with user-controlled font scaling in browsers. Perhaps you might consider learning how to handle the text size changes, the way countless developers did before you.
Frankly, I'd like to just define the text with dp but can't find a way using code to do so (none of the TypedValue constants seem to support it).
dp
is also abbreviated dip
and stands for density-independent pixels. The corresponding TypedValue
is COMPLEX_UNIT_DIP
.
Upvotes: 1