1

With the use of weight my layouts are really perfect on every screen size and density. Every view is perfectly scaled. Unfortunately there is still a big problem with characters size: no matter if I define text size with sp or dp, it still resizes based on density and not on size of the screen, so on tablets text is microtiny!!

What's the best solution for this problem?

  • Shall I define different layouts for tablets? And in that case, how can I do it?
  • Is there a way to auto-size the text, in xml or by code (I don't care much which one, if it works)?

Thank you very much.

Beppi's
  • 2,089
  • 1
  • 21
  • 38
  • Have a look here http://stackoverflow.com/questions/4185507/layout-for-tablets-in-android. So yes you have to define a different layout. – grattmandu03 May 23 '13 at 15:56

3 Answers3

5

You can create separate styles for different screen size qualifiers small, normal, large, xlarge, and a bunch of new sw<N>dp, h<N>dp, w<N>dp

Supporting Multiple Screens

ooops
  • 326
  • 2
  • 14
1

Solution 1

use different layouts for different screen size

Solution 2

Use customView and change the text size dynamically. For example

    public class CustomView extends TextView{
         ....................

        @Override
        protected void onDraw(Canvas canvas) {

                 calculate the view size and change the text size

        }

    }

UPDATE

To measure the size you can use following

        float size = getHeight() * .8; // getheight will return view's height
        setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
stinepike
  • 54,068
  • 14
  • 92
  • 112
0

You can make use of dimens.xml which you need to create in your values folder and create values folder as values-large values-small values-xlarge etc.....

newBie
  • 118
  • 11