4

I wonder how to make application look the same on different devices. I have read Supporting Multiple Screens many times but I still can't understand how to live.

Here is a sample layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
    <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Hello World, MyActivity"
            android:textSize="30sp"
            />
</LinearLayout>

There is Galaxy S II (480x800) and Sensation XE (540x960). They are both hdpi, physical screen size is almost the same. I expected to see the same looking on both devices but in fact text on 540x960 is smaller then on 480x800: enter image description here (left is 480x800, right is 540x960)

I tried to specify text size as dimension resource and make separate folder values-w540dp but it took no effect.

How do you guys make your application look the same on different hdpi devices?

MKJParekh
  • 34,073
  • 11
  • 87
  • 98
darja
  • 4,985
  • 9
  • 33
  • 47
  • Technically those 2 things are equal. It can make the text the same size, but it can't make the smaller screen wider :) Notice how "Hello" ends roughly in the same spot on the end of "Demo"? – Bill Mote Nov 08 '12 at 13:43

3 Answers3

3
android:textAppearance="?android:attr/textAppearanceLarge"

android:textAppearance="?android:attr/textAppearanceMedium"

android:textAppearance="?android:attr/textAppearanceSmall"

These atributes may solve your problem here.Otherwise you have to setup your layout dynamically with some ratios(or factors you generate like :textSize=factor*height) using your screen height and width.

Ercan
  • 3,705
  • 1
  • 22
  • 37
0

Have a look at metrics , if you specify your textsize in dp (Density-independent pixels) it should work. The default size for text should be around 14dp. (TextAppearance.small)

Joep_H
  • 362
  • 2
  • 10
0

2 Sites that might be helpful as there are some nuggets in both related to your problem, however, neither is an exact 1-2-3 how to correct the issue you're seeing:

Bill Mote
  • 12,644
  • 7
  • 58
  • 82