Optimal TextSize in a TextView - android

Is there a method or do you know a possibility to find out the optimal text size in a text view? I think this could be very usefull if you have a changing text in a text view. This could also solve the Problem, that text on a small Screen is to big and the same text size is to small on a big Screen.

A very helpful tool in creating layouts that can fit all screen sizes is the attrs.xml.
Like drawable-hdpi, drawable-mdpi, etc., you can customize the size of texts (and whatever attribute you want to customize for different screens) by creating a size-specific values folder.
Android also comes with built-in "recommended sizes". Try typing in
?android:attr/text
ctrl+space to see the list of recommended sizes for some of the most common elements that has text in it.
For TextViews you can also modify its style (not textStyle) and use some built-in values such as
#android:style/TextAppearance.Medium

Related

Textview fontsize SP vs android resource dir... Is there a resource dir for font size config?

In my app we are using mostly SP in order to help visually impaired people.
However, sometimes font is just too big or too small and android components don't work very well, cutting some text or miscalculating the appropriate width and height of the textview.
We have been using autoshrink components but still there are some edgecases that break the app. For those cases, I want to create specific layouts.
My question is, does the configuration change fall into some of the resource directories of the app? I mean, if The user chose large font, will I be able to place special layouts in the ldpi or any other directory for example?

What's the different between "android:textSize" and "textSize" in AOSP?

In AOSP Code ,there are many TextView Resource use "textSize" in style.xml to limit the text size, by in a normal alllication ,they use "android:textSize" to limit text size.
So what's the different between those two things?
In style.xml file the textSize is used for mentioning default text size value of that style.
so whenever you call that style in your view you will get that size of text.
Other hand in android:textSize we hard code the text size of that view.
Hope that make sense.

Android one PNG screen image with EditTexts located on screen

I have a full screen png image with all descriptive text for each EditText. I want to place the six EditText input areas at the correct positions on the screen.
I understand the different layout folder names for different screen sizes, densities and orientations. So I would have different layout XML files for each.
My problem is how to place the EditTexts at the correct location, and have them scale what would be small amounts with the small variations of sizes as the full screen png image will scale.
I believe that I should not specify locations, even with density independent pixel (dp |dip), as they may not work in future versions.
I cannot find anything on searching for this problem. What I can think of is a Relative Layout with blank or transparent dummy TextViews pushing the EditTexts to the correct positions.
My reasons for doing it this way with one png image for all the non-EditText parts of the screen are (I think)
- Can get a nicer screen image
- Is more efficient to place one png ImageView on the screen
- Is how it was done in another mobile environment
Any thoughts or suggestions?
My recommendation is that you remove any text parts and other that needs to be aligned from the background image, then create a RelativeLayout where you can add these as real TextViews/EditTexts.
This will give you the best result and flexibility considering all the different screen sizes and resolutions available for Android phones and tablets.

Android application GUI Design

I have a problem in android application interface design(GUI).
For example when we insert an editText field the height is too big. Yes we can change the width and bit modify.
But does anyone have any link of a reference or idea of how to design the exact design we want. And when we add 2 -3 editText(views) the entire space finish. have to scroll to go through entire page.
And to design the GUI for all kind of screen sizes, what are the standard things that have to follow. I searched but didn't find exact answer.
Any link to a good reference or idea is highly appreciated.
Thank you
set the layout of text edit with:
layout_width="wrap_content" //wrap_content fill the dimension like the content and fill_content all the space free
layout_height="wrap_content"
In order to make your app resolution free you have to take care for the following items
Widgets in your activity (wrap_content, match_parent, fill_parent, or left, right gravity in relative layout etc)
Icons and Images in your activity (You have to keep icons of 3 different sizes in 3 different drawable folders, hdpi, mdpi and ldpi and if you are making your app for tablets also then xdpi (i think))
You have to provide similar text sizes for different screen sizes (3 sizes should be suffice I believe) You can make a general xml file for this and keep it in another drawable folder.
Let me know if you need more detail on this.

Layout that enlarges buttons for larger screens?

When specifying the size of buttons and toolbars, I've been using the "device independent pixels" (dip) feature of the XML layout files. By using dips, I can specify the physical size of the GUI components, which is good for ensuring components are always readable and clickable for all screen sizes. For example, my app has a horizontal toolbar that is about 50dip high at the top with several 40dipx40dip buttons along it.
However, buttons whose physical size is just big enough to see and click on for a small screen aren't very usable on tablets. For example, my toolbar will contain huge amounts of whitespace, the buttons are hard to see (as you tend to hold the tablet further away from your face) and the buttons are hard to click on in practice (as they are small proportional to the screen)
Are there any resolution independent approaches for dealing with this?
I know I can use "layout_weight" to stretch components so I can specify what percent of the screen to use but this is going to be really cumbersome for lots of buttons (also, my buttons need to be square) if I have to do this mostly manually. I can use different layout files for each device, but this is a pain.
Are there any resolution independent approaches for dealing with this?
Use dimension and drawable resources.
You haven't indicated how your buttons are "40dipx40dip".
If they are set that way via specific heights and widths, instead of having 40dip in a layout or in a style, use #dimen/toolbar_btn. Then in res/values/dimens.xml define that to be 40dip and in res/values-large/dimens.xml (or maybe res/values-large-land/dimens.xml) define that to be, say, 60dip, or whatever works for you.
If the buttons are "40dipx40dip" because of images, then it's merely a matter of creating somewhat larger images for tablets and putting them in, say, res/drawable-large-mdpi/ resource directory.

Categories

Resources