Here i develop one Android application, which can run on all screen size and resolution devices. But one problem is there my TextView's
Fontsize is same on all the Screen-Size. I want to change FontSize
according to Different ScreenSize
and Screen Resolution.
Thanks in Advance.
Use the code from Screen Category or use getSize() method like:
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
as described here to get the screen size and and then set the font size accordingly using setTextSize() method, you can also consider using sp unit for font size.
First, if you have not done so already, you should read this
http://developer.android.com/guide/practices/screens_support.html
To provide any resource, including styles that could apply to text, you should read the section Using configuration qualifiers
Another useful document here http://developer.android.com/guide/topics/resources/more-resources.html#Dimension should help you with selecting the right unit of measure for text, ideally you want to use sp's as explained in the excerpt:
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 the user's preference.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With