如何为不同的密度指定不同的布局尺寸

mic*_*ael 3 android

你能否告诉我如何指定不同密度屏幕的布局尺寸?即不同密度的布局是相同的,但是某些维度是不同的.我怎样才能做到这一点?

谢谢.

Vin*_*yak 11

//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.
Run Code Online (Sandbox Code Playgroud)