Differences in font size between resolutions
I developed my app on 240 hdpi WVGA800. The textsize on some of my buttons were much too small, so I had to change them to 50sp. It looks good on what I developed it on but when testing on 120 ldpi QVGA and 160 mdpi HVGA, the text is slightly cut off. Also, when testing on 3.0, the text is much too small. How do you handle this?
Edit: It actually only appears to be an issue in 1 layout. The layout has nested linearlayouts, with weight=1 so that every row is equal size and fills the screen. The layout_weight for LinearLayout so it stretches to fit the screen vertically. And for each button so they stretch to fill the screen horizontally.
<LinearLayout>
<ViewFlipper>
<LinearLayout>
<LinearLayout android:layout_weight="1">
<Button android:layout_weight="1"></Button>
<Button android:layout_weight="1">&开发者_开发技巧lt;/Button>
<Button android:layout_weight="1"></Button>
</LinearLayout>
<LinearLayout android:layout_weight="1">
<Button android:layout_weight="1"></Button>
<Button android:layout_weight="1"></Button>
<Button android:layout_weight="1"></Button>
</LinearLayout>
<LinearLayout android:layout_weight="1">
<Button android:layout_weight="1"></Button>
<Button android:layout_weight="1"></Button>
<Button android:layout_weight="1"></Button>
</LinearLayout>
<LinearLayout android:layout_weight="1">
<Button android:layout_weight="1"></Button>
<Button android:layout_weight="1"></Button>
<Button android:layout_weight="1"></Button>
</LinearLayout>
</LinearLayout>
<LinearLayout>
</LinearLayout>
</ViewFlipper>
</LinearLayout>
You need to set your text sizes using "dp" - see here: http://developer.android.com/guide/practices/screens_support.html
Density-independent pixel (dp) A virtual pixel unit that applications can use in defining their UI, to express layout dimensions or position in a density-independent way.
The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform (as described later in this document). At run time, the platform transparently handles any scaling of the dp units needed, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: pixels = dps * (density / 160). For example, on 240 dpi screen, 1 dp would equal 1.5 physical pixels. Using dp units to define your application's UI is highly recommended, as a way of ensuring proper display of your UI on different screens.
You can anyways give separate font sizes for separate screens, using dimens entry in value.xml. Have different folder for different screen size (values-large, values-xlarge etc)
精彩评论