Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text size with different resolution

i am using a galaxy tab 1, 7inch hdpi and a galaxy tab plus, 7 inch hdpi but more resolution, and in my application, the text can be read fine in galaxy tab but in galaxy tab plus there are too much small. Im using sp in font size and layout-large. Any idea? Thanks

like image 682
colymore Avatar asked Sep 27 '12 11:09

colymore


People also ask

How do I change the font size based on screen resolution?

Select 'Display'. Select the 'Change display settings' link towards the top of the window on the left-hand side. In the 'Resolution' section, select the pull-down bar, and a slider bar should appear. Move the slider bar down to make the text larger, or move it up to make the text smaller.

Does screen resolution affect size?

Screen size is measured in inches, e.g. 5”, 10”, 13”, 17”, etc. Screen size and screen resolution aren't directly related. For instance, you can have a 10.6” tablet with a resolution of 1920 x 1080 and a 24” desktop monitor with the same resolution.


2 Answers

This should be some help for you if you want to set size programmatically. Text will show in the same size on each device

TextView text = new TextView(this);
text.setText("text");
text.setTextSize(16 * getResources().getDisplayMetrics().density);
like image 67
Dr Glass Avatar answered Oct 25 '22 12:10

Dr Glass


By hardware specifications Galaxy Tab 1 is MDPI device, but because it uses Android 2.x Samsung set it programmatically to use HDPI resources. So I can advice you to make following:

  1. Create file dimens.xml in values directory.
  2. Put there <dimen name="font_size">30sp</dimen>. This is default font size.
  3. Create file dimens.xml in values-large directory.
  4. Put there <dimen name="font_size">20sp</dimen>. This is font size for galaxy tab 1.
  5. Create file dimens.xml in values-sw600dp directory.
  6. Put there <dimen name="font_size">30sp</dimen>. This is font size for other tablets with Android 3.x and newer.
  7. In layout specify android:textSize="@dimens/font_size"
like image 21
vasart Avatar answered Oct 25 '22 13:10

vasart