What is recommended text size ratio between mobile and tablet device?
There is an app for a mobile device and I need to make the same for a tablet device. If font size in mobile app is 16dp, what should be in tablet app?
There must have been some multiplication ration which I can use to best decide on text size for a tablet app. Android design web site does not say much about this.
PS. I know that I can tweak each text by testing it on a device, but I am looking for a recommended ratio.
EDIT
not 16dp, but 16sp. Sorry!
Actually we developers need not worry about that ratio. I simply externalize font size values into res/values/dimensions.xml and use sp as a unit.
<resources>
<dimen name="my_font_size">16sp</dimen>
...
Scale-independent Pixels - this is like the dp unit, but it is also
scaled by the user's font size preference. It is recommend you use
this unit when specifying font sizes, so they will be adjusted for
both the screen density and user's preference.
Just saw your edit: Since sp already takes user prefs and dpi into account all you can do is to assign different font sizes via the resource system. And to my knowledge there is no single magic conversion number for tablets to phones. Just think about the multitude of different screen sizes out there.
You could however use a custom style which uses one of the theme defined values for text size.
Id like to hope that device manufacturers know which font size has good readability on their devices.
<style
name="MyTextStyle"
parent="#android:style/TextAppearance.Medium">
</style>
If you use dip's instead of pixels, it should automatically look right for both phones and tablets. Tablets are typically mdpi devices (scale factor 1).
if you're interested, you can find more information on the scaling factors for screens with different densities here: http://developer.android.com/guide/practices/screens_support.html
Related
I've been using dp for dimensions and sp for text size for 3 years now, ever since I've started developing apps for Android.
But recently, I've been joined with a couple people that don't believe in dp and sp saying "it doesn't show the same on all devices".
The method they've used is:
When setting the text size, you don't use 24 sp nor 24 dp, you set it as 24% of the screen width or height in pixels. in this way, the text is always the same size in pixels on all devices (including tablets).
How correct/valid is this method? What is the professional way to design? What is the opinion of a professional Android designer to this method?
Don't know how good % can replace dp, but don't use it as a text size.
sp is great because users can resize it by changing their preferred text size in the device settings. Don't take away this possiblity just because it makes your design easier for you.
Accessibility > Design
See this guide for reference: Support different pixel densities
When defining text sizes, however, you should instead use scalable pixels (sp) as your units (but never use sp for layout sizes). The sp unit is the same size as dp, by default, but it resizes based on the user's preferred text size.
Best unit for text is sp and for dimensions best unit is dp.
That is given perfect result of in which you want.
In most of developer use this unit for text and dimensions.
I try for your % but that is not work in my app.
dp stands for density independent pixels. Its goal is, to define a more or less physical dimension. E.g. 48dp are about the size if a finger tip, and that's why tappable icons (e.g. on ActionBar) should have that size.
So for UIs you should always use dp (and sp for texts). It also has the advantage, that you can show more data on a larger screen (e.g. more items in a list are visible etc.).
If you're using % of the screen size, you are doing the exact opposite. On a small device 24% it will be small (physically speaking) on a large tablet it will be large.
Using % might make sense if you're developing a game for example and you want the same image shown on every device, large or small.
DP/SP Does not claim to be the same on all screen sizes but about the same size across screen densities. The reason it is only about the same size is that density is broken up into categories (e.g. mdpi, hdpi, xhdpi...).
You don't want the text to be relative to the screen size because then the text will be really small for devices that have a small screen and really large for devices that have a large screen. Instead you want the font size to be comfortable to read and about the same size on large or small screen. The large screens will just have the advantage of more text on the screen at a time.
In addition as other users have mentioned sp (and apparently now dp) can be scaled based upon user preferences which is really helpful for people with poor eyesight.
I would like to create a adaptive UI for both mobile and tablet devices. I would like to know for example for mobile devices if I give android:textsize="2dp then how much I should give for tablet devices. I know I should give them in values-w820dp and appropriate folder but how to calculate the difference of this dp. I couldn't find any resource for this. Help me out.
(1) For most text, it's best to size it in sp units so it scales automatically relative to the user's text-size preference. Folks with lesser vision can pick larger text and then be able to read your app without eyestrain.
(2) If you need some text to appear in a fixed size, e.g. a big headline, then use dp units so it scales automatically relative to the screen's pixel density. (Pixel density is independent of the overall screen size. It's a high vs. low density thing, not a phone vs. tablet thing.)
But don't use size 2dp! That'd be unreadably tiny -- the height of 2 physical pixels of a 160 dpi screen.
(3) If you need some text that uses approximately a fixed proportion of the screen size, then it makes sense to either define screen-size-dependent parameters, e.g. in values-w820dp, or to size it in code.
(4) If you need some text in a fixed number of pixels tall even when the pixels are really tiny, e.g. to draw into a raster image, then use px units.
See Supporting Multiple Screens - best practices.
There are no strict rules here. You can have android:textsize="2dp on your tablet as well if you wish so. You can have a look at the following android developer page which tells how to support tablets and contains chapter called: 5. Adjust Font Sizes and Touch Targets
Hello I am using different textsizes depending on different screen sizes.
Like:
values-small: dimens.xml -> ?
values-normal: dimens.xml -> 10sp
values-large: dimens.xml -> ?
values-xlarge: dimens.xml -> ?
I want to know if there is a formula to set the right sizes depending on small, large, xlarge instead of setting sp size by testing it on different screens^^?
second question: is values-normal neccessary, isnt "values" folder == values-normal?
third question: what happens when I declare dimens.xml for small, normal, and large and the device is a XLARGE device will it use dimens.xml from values? or valuse-normal? or the next smaller one values-large?
thank you
I want to know if there is a formula to set the right sizes depending on small, large, xlarge instead of setting sp size by testing it on different screens
Not really. Many apps do not change their font size at all based on screen size, just as most Web apps do not change their font size based on browser window size. Of course, you are certainly welcome to specify different <dimen> resources for different screen sizes, including dimensions for use with text. And there's nothing stopping you from using an algorithm like the others suggest; just understand that there's no real reason to use that algorithm. To put it another way, a graphic designer should be telling you how big to make the text, not a calculator.
Moreover, the -small, -normal, etc. buckets are not used as much anymore, in favor of the more flexible -wNNNdp, -hNNNdp, and -swNNNdp buckets.
isnt "values" folder == values-normal?
No.
Suppose you have res/values-small/, res/values/, res/values-large/, and res/values-xlarge/. Further suppose that each resource set defines a text_size dimension resource, and you use that in in layouts (e.g., #dimen/text_size).
A -normal device will then pull from res/values-small/, as -small is for small screens or larger. Your res/values/ version of the resource will never be used. Hence, the typical pattern would be not have res/values-small/, putting your -small resources in res/values/, and overriding that default value in res/values-normal/, res/values-large/, and res/values-xlarge/.
what happens when I declare dimens.xml for small, normal, and large and the device is a XLARGE device will it use dimens.xml from values? or valuse-normal? or the next smaller one values-large?
It should pull from res/values-large/, as that is the closest match among the qualifying resource sets.
This is the common problem in majority of Android projects to support varied screen sizes.
In short, you can make use of scalable DP and scalable Font approach.
Android project structure inherently allows specifying different font size (SP) and margin values (DP) by defining them in dimens.xml files for supported screen sizes. But the problem that still remain is - what values to be used ? UX designers normally provide style guides for only one set (e.g. 360x640 DP screen size) and don't provide for all other supported screen sizes. So the problem to use right vlaues for other supported screen sizes still remain unanswered.
One good solution (per my understading) is to use readymade scalable dictionary of dimens.xml files, something similar to the dictionary of files provided by this library. After adding these xml files to project, you just need to use the keys in your layouts, then Android automatically uses font/margin value from respective directory. Please refer here for visual difference - with and without this approach.
I use the ratio 0.75 : 1 : 1.5 : 2 same as for DPIs. It works fine.
I'm designing an android activity which I want it can be compatible with all screens resolutions. Right now, I did it knowing that the screen will have 1024x600pixels, and in the layout_weidth and height, I used absolute pixels... (I started with dp's but it doesn't work in my mobile, but it works in the emulator... very confusing, so I decided to try with pixels and they worked) but if I get another resolution, then it crash...
So I though in creating a xml with percents of the actual resolution of the screen, so it can be compatible with all the screens...
But thoughting, what can I do with the textSize, for example? How can I make it compatible?
I need some advice... thanks
Using Relative layout is a better option
Use dp - density independent pixels for UI components and sp for Text sizes
sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.
Received an email from my first Motorola Droid user. The new 480x854 resolution introduced in Android 2.0 (as opposed to 320x480) is wreaking havoc with my user interfaces. Everything is smaller and ill-positioned.
I was under the impression that if we follow the XML layout guides we were resolution-safe, as no absolute coordinates are used. Does anyone have experience in making the UI resolution-safe? Will we need a main.xml for each resolution times each orientation?
Which dimension units did you use?
AFAIK using dp and sp should keep you safe.
From documentation:
dp
Density-independent Pixels - an abstract unit that is based on the
physical density of the screen. These
units are relative to a 160 dpi
screen, so one dp is one pixel on a
160 dpi screen. The ratio of
dp-to-pixel will change with the
screen density, but not necessarily in
direct proportion. Note: The compiler
accepts both "dip" and "dp", though
"dp" is more consistent with "sp".
sp
Scale-independent Pixels - this is like the dp unit, but it is also
scaled by the user's font size
preference. It is recommend you use
this unit when specifying font sizes,
so they will be adjusted for both the
screen density and user's preference.
The eclair emulator works wonders for these issues, also make sure to read:
http://developer.android.com/guide/practices/screens_support.html
Your application responds to different resolutions based on many factors, even the min-sdk.
Also, from the page, are some best practices:
Prefer wrap_content, fill_parent and the dip unit to px in XML layout files
Avoid AbsoluteLayout
Do not use hard coded pixel values in your code
Use density and/or resolution specific resources
Aside from the resolution difference, the other thing to consider is that the Droid's WVGA screen has a different aspect ratio from previous devices like the G1. In many older apps that I've downloaded, this manifests as a gap at the bottom of the screen, or elements that are vertically misaligned in portrait mode. You may want to try running your app in the emulator with a WVGA skin to check for any hidden assumptions that your layout makes about the aspect ratio.