Resource folder for different text sizes - android

I'm developing and Android application that will support changes in the size of its text when the user changes it on settings.
For this reason I want to know if there's a way for me to separate my application resources according to the font size changes. For example, can I create an resource folder named like "drawable-huge" (the font size). If so do you know the suffixes I can use it on the folders? If that isn't possible, do you know any other thing I can do to prevent UI problems when the font sizes are bigger or smaller?
Thank you.

You can use something like this
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 65);
which 65 is the font size in sp
for more information vist http://developer.android.com/reference/android/widget/TextView.html#setTextSize%28int,%20float%29

Related

can we create values folder on the basis of both size and language?

I have idea on separating values folder based on the size like ldpi, mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi and small, large ,normal,large,xlarge . And for separating the folders based on language we'll use values-(language code). Apart from this can we separate the values folder base on both size and language? If possible how?
I want to show for small devices with font size of 12sp for one language and 18sp for another language. like values-small-te and values-small-en.
I tried with values-small-te but not worked :( . let me know if any way exists.
thanq in advance.
For language
you can write in String file that is you can create different files for different languange in string directorie
like
strings.xml(hi), strings.xml(guj), strings.xml(ta)
For font
you have to create different file in dimens directories to support different devices
like
dimens.xml(hdpi), dimens.xml(ldpi), dimens.xml(mdpi),
dimens.xml(xdpi), dimens.xml(xxhdpi), dimens.xml(sw480dp) ,
dimens.xml(sw600dp) , dimens.xml(sw720dp)
Please check this link to create directories.

Android resource qualifiers for Huge/Small fonts (accessibility)

I have searched the documentation and have not found an answer so here we go:
Does Android have a resource qualifier to select between different resources when accessibility options are used? Like when the user sets font size to Huge.
I would like use different dimensions on some views when dealing with Huge/Small fonts.
Thanks in advance!
No, there is no resource qualifier for font scale. I assume you're aware of the sp unit for specifying text size. I would suggest either -
Make your layouts more flexible and sized based on their contents.
You can use getResources().getConfiguration().fontScale to determine the scale at runtime, and select or adjust your layout(s) accordingly.
This may cause more harm than good, and the docs explicitly say not to do this, but you could try using sp rather than dp for your various layout parameters as well.

Varying font sizes when using different .ttf fonts with no change to the sp

Problem: When implementing a custom font I notice quite a big change in the font size. (Without any altering to the font size in the XML file)
This is causing a significant variation between the Actual font size in comparison to the size shown in the Graphical layout in ADT. (Visually about 20sp smaller)
I am building a timer application and want to use a Digital Looking font.
Question: Can a .ttf file affect the font size relative to a constant 'sp' ?
To answer my own question.
YES. a .ttf file does have a 'base font size' and this may vary from one .ttf to another.
As stated in my comment above:
I figured out how to change the base size of a .ttf using FontForge (fontforge.org) There is a great tutorial on how to do this here: forum.xda-developers.com/showthread.php?t=990853 I did have to play around with more options then noted in the tutorial to get my font just right but it works perfect!

Relative "res/values" folder in Android to scale styles based on screen size and resolution?

I wonder if it's possible to have a folder such as res/values-small or res/values-hdpi in the same way that it's possible for the layout folder? I'm thinking about styles that should automatically scale depending on the screen resolution and size.
Or do I simply create a separate style for other resolutions in the same values/style.xml file?
Yes you are right all the names you mentioned are valid. To experiment more with different filenames use ADT.

android make application sensitive to font size

When I use sp as my font size unit in the XML file, I go to spare parts and change font size, my app's font size is not changing. Does anyone know a way to resolve that?
The font size feature in Spare Parts is a holdover that doesn't have any effect on anything else.

Categories

Resources