Is it possible to change the default-fontsize only for one app?
So i can use the "sp" units at all my fonts?
The problem is that my customer doesn´t wan´t that his employes changes anything in the android-settings. So i am searching for a solution to change the font size in my app. Of course i could implement my own dynamic font size by programmatically changing the size of each label when the user chooses another size. But i think that is to complicated and should by the last way.
Best regards
Yannick
Related
So I have read possibly everything about the difference between sp and dp. I can say that I do understand why sp is better than dp regarding text size. One thing I don't understand and want some help with is how do I make the text look the same with every possible font size the user has selected for their phone? Is it that bad to use dp for text size? (I know that the app won't take the user's phone font size into consideration but at least it will look the same across the board.) Any advice would be appreciated.
To make the text look the same irrespective of the users' choice, use dp. To change the text size according to users' choice use sp. So, if you have a constraint that the text size should remain the same use dp.
Is not bad at all to use DP as text size. It just won't follow the users preferences regarding text size. We have to use the tools we have, to best fit our needs. I always use DP in elements wich i need to maintain the layout. If you don't want the text size to change, use DP. Some times i use textAutosizing When the text changes. And often i use sp, when dealing with "content" text, wich can grow and scroll, shrink and fit.
When I change the android text size to xlarge through the system, my app will go out of range. I tried to find some solutions to solve this problem which is AutoResizeTextView, but I do not find good solution for editText and something else.
What is the correct way to solve the text size changing issue, I do not want to set the text size, I want to depend on the user setting to change it and auto fit screen.
Thank you
Is there any way to change the layout of your app based on what text size the phone is set to? I know you can set your text so it will be static (stay the same size) but I've had some users complain because the app doesn't look good because of the large text. These are mainly older people who need the large text and it would be nice if there was an easy way to accomplish this without splitting one activity into two separate ones so they could still use it. Any ideas?
I am writing an app about eye test. It is necessary to set the standard text size. I used the following code but it showed what I did not expect.
Typeface type=Typeface.createFromAsset(getAssets(),"Optotypes.ttf");
textView2.setTypeface(type);
textView2.setTextSize(TypedValue.COMPLEX_UNIT_MM,25);
textView2.setText(randomLetter);
I expected the textview show a 2.5cm letter but it is not the exact length/height still.
This situation appear also on different device.
The next problem is that the size is different between the original font and ttf I added. (the original font didn't show the text with 2.5cm also.
Is my code wrong or anything else i missed ? Thanks guys . it is important to me.
I think you're missing how Android handles text sizes.
In Android, you should specify text size in SP units, so Android can scale it accordingly to the user's font size preferences. Never specify hardcoded pixels or centimeters.
Check this references for documentation on the subject:
http://developer.android.com/guide/topics/resources/more-resources.html#Dimension
http://developer.android.com/reference/android/widget/TextView.html#attr_android:textSize
What is the difference between "px", "dp", "dip" and "sp" on Android?
If you want to set the text size in SP programatically, you can do this
// same as android:textSize="15sp" in XML
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
-- EDIT
Keep in mind that by just setting a certain text size it doesn't mean that every letter will be of that size. Remember that there are multiple letters with multiple sizes. For instance, with a size of 20mm, this is what you get
Because Android needs to accommodate every possible character in a textview with the size you provided. That being said, textSize is not 100% accurate to what you provide to it.
If this is not enough for you, please provide more details of the problem you have at hands.
Now I developed native application in Android and I need to increase the font size of whole application using preferences how do I do that? Can anyone help me?
Thanks
Raj.
You cannot change the font size for the entire project. But you can change the font size for each activity. Just check the below link. It will help you
Is it possible to set font for entire Application?
You can't really do this. I think the least painful way would be to extend TextView plus whatever Views you want to use the new font size. Set your default font size there, then just use your custom TextView in all your layouts.