你能告诉我如何为不同密度的屏幕指定尺寸吗?
也就是说,在不同的密度下,布局是相同的,但有些维度是不同的。
我该怎么做?
谢谢您。

最佳答案

//1.create different dimens.xml in different resource folders as below

 res/values-ldpi/dimens.xml
 res/values-mdpi/dimens.xml
 res/values-hdpi/dimens.xml

 //Then Android will decide which file to use.

//2.Create  dimensions values in respective dimens.xml file according to the need as below


 <!-- in values-ldpi/dimens.xml -->
 <dimen name="textSize">25dip</dimen>

// and..

 <!-- in values-mdpi/dimens.xml -->
 <dimen name="textSize">20dip</dimen>

// etc.
// 3.Don't care about resolution Android will take care of which resource to fetch.
// 4.Mention size in  dp instead of pixels.

09-30 20:55