I have values-xxhdpi folder having dimens.xml file, i set the font size 34sp in nexus 5. When I put this on the samsung s5 the font looks very small. Is there any possible way of having the font size look the same (size wise) on both devices?
android:textSize="#dimen/font_size_34sp"
I have find screen size difference
Nexus5 4.9"
S5 5.1"
Provide me generic solution, if possible I want to be able to do this in XML.
You could have a method at run time (onCreate) to get the screen dimensions then based on that re-size the font dynamically.
As different phones have the same DPI but different screen dimensions.
Please also view this
Related
I am testing my app on S7 and S10e devices. For both devices, xmls are rendered from layout_normal_xxhdpi folder. And I am setting my textview text sizes with dp. But somehow, texts are rendered in S10e are much smaller. How I can solve the issue?
1dp has a different physical size in every screen, dp's take pixels into account. You can learn about it here:
https://youtu.be/zhszwkcay2A
You should use SP instead of DP. SP's remain the same physical size between different screen sizes. If you get variations of size with the same SP in different screens it is not made on purpose. Still this is the recommended way to do it.
my phone is galaxy s9 that is 5.8 inch and xxhdpi. And my virtual test phone is nexus 5 that is xxhdpi but the screen size is 4.95 inch. The imageview from the Galaxy S9 appears to be cut off from the Nexus 5. Layout-xxhdpi applies to the same device, with some looking right and some looking fired. How can I solve this?
I would like to recommend you use Vector drawables.
The major advantage of using a vector drawable is image scalability.
It can be scaled without loss of display quality, which means the same
file is resized for different screen densities without loss of image
quality.
Vector drawables allow you to replace multiple png/jpg/jpeg assets with a single vector graphic, defined in XML.
FYI- For responsive Textsize issue, You should use SDP
I'm using custom fonts for all components in my application. All font sizes are defined in dimens.xml file in sp format.
However fonts are bigger (wider?) on HTC ONE and smaller on Galaxy S4 which messes up my layouts. Any idea how can I correct this?
Sorry, my fault.
I just realized, that sp calculates font size based on user preferences.
Hii friends i had a problem related to font sizes .
I had create an android application now the problem is i had set the font sizes for large hdpi screen but these font sizes are not set on device s3 mini which is a large hdpi device .
On the other hand on emulator it reflects the changes madein Font Sizes.I don't understand what is the problem.I am posting two images .please help if any one know about the problem.
Specify the font size in sp (If you had given a font size as 10px or dp then replace it as 10sp).
I have an S3 mini, and it is not a large-hdpi device. It is normal-hdpi. That probably explains why your changes have no effect.
I've started work to get my games to scale nicely on the higher-res displays like the Xoom and Galaxy Tab 10.1.
I've made use of the ldpi/mdpi/hdpi/xhdpi folder naming convention for my resources which works nicely for layouts and graphics, but not so much for text size scaling. The problem is that an Evo and a Galaxy Tab 10.1 (for example) are both mdpi devices and will map to the same layout file. Yet, I need to scale the text size for some of my TextViews differently for these two devices. For the record, I'm using dp for the text size units.
Any ideas would be much appreciated.
Mike
Consider using sp for text sizes.
Apply different layouts based on screen size (not screen density), as described at http://developer.android.com/guide/practices/screens_support.html.