Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

resources - Different values folders in android

I am creating different values folders in my app (values, values-ldpi, values-mdpi, values-hdpi, values-xhdpi, values-nodpi, values-w360dp-mdpi). But some devices that belong same category. But having different screen sizes. But I see give font size according to device densities in this the answer provided by @PankajSharma suggest to create folders like-

res/values/dimens.xml    
res/values-small/dimens.xml    
res/values-normal/dimens.xml    
res/values-xlarge/dimens.xml

I want to know what is the difference b/w my way and the other way? I think the answer provided by @PankajSharma is easy. I also want to know which way is better?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The approach you are using is a valid approach, but a little outdated. From HoneyComb, there is a new way to fix all of this. Your resources folder should now look like this:

enter image description here

Please refer to the link I have posted and familiarize yourself with Smallest Width concept.

Hope this helps :)

EDIT: Adding to this post, try to establish some kind of standardization in your dimens.xml, something like this:

enter image description here

Doing this makes it easier to maintain code, plus it reduces the number of dimen folders. Normally rather than having values-hdpi, values-xhdpi, etc. files like values-sw480dp-xhdpi might have more values to adjust, but then again all of this is contextual.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...