Android – how to specify different layout sizes for different densities

Can you tell me how to specify the layout size of different density screens? That is, the layout of different densities is the same, but some dimensions are different. How can I do this?

thank you.

resolvent:

//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.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>