Different value folders in android

I create different values folders in my application (values, values-ldpi, values-mdpi, values-hdpi, values-xhdpi, values-nodpi, values-w360dp-mdpi) . But some devices that belong to the same category. But with different screen sizes. But I see the font size in accordance with the density of the device in this answer provided by @PankajSharma, it is proposed 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 between me and different? I think the answer provided by @PankajSharma is simple. I also want to know which way is better?

+35
android dimensions resources
Jan 22 '14 at 10:28
source share
3 answers

The approach you are using is a valid approach, but a bit outdated. From HoneyComb there is a new way to fix it all. Your resource folder should look like this:

enter image description here

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

Hope this helps :)

EDIT: dimens.xml added to this post, try setting some standardization in dimens.xml , something like this:

enter image description here

This simplifies code maintenance and also reduces the number of dimen folders. Usually, instead of values-hdpi , values-xhdpi , etc., Files such as values-sw480dp-xhdpi may have more values ​​to configure, but then all this is contextual.

+70
Jan 24 '14 at 4:03
source share

Create a single layout for the default 4.7-inch (hdpi) screens in the layout folder and in the size folder. This is your Superset .

Now let's say you need your layouts for 7-inch devices. Create values ​​folder-sw600dp for 7inch in portrait orientation

Now let's say that you want your layouts for 10-inch devices to create -dw720dp folder values

NOTE. - For landscape, just add "-land" before the folder names.

Now let's say that you have new devices, such as Xperia SP (4.7 'and XHDPI) and Nexus 5 (5 "and XXHDPI).

To do this, you can create values-xhdpi and values-xxhdpi-folders and similar add -land for landscape orientation.

I hope you understand how to create folders.

Now your superset is defined in the values ​​folder. Most measurements will only be used here. Now run the application on other devices. No matter what the mismatch is, just add this specific size to your values ​​folder

To check which folder your layouts, images are used from, use my trick.

Create five identical lines and put in it all the values, such as: Default screen Screen 4.7 XHDPI screen MDPI screen

Create five drop-down folders, most of them already exist: - drawable-hdpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi Place the screenshots below in their corresponding folder under the same name

enter image description hereenter image description hereenter image description hereenter image description hereenter image description here

Here's what my res folder looks like, and I support all devices from screen 4.7 and above: -

enter image description here

+15
Jan 24 '14 at 4:08
source share
 <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> <!-- Various Text Sizes --> <dimen name="text_size_extra_small">10sp</dimen> <dimen name="text_size_small">12sp</dimen> <dimen name="text_size_medium">14sp</dimen> <dimen name="text_size_normal">16sp</dimen> <dimen name="text_size_large">18sp</dimen> <dimen name="text_size_extra_large">20sp</dimen> <dimen name="text_size_super_large">50sp</dimen> <dimen name="text_size_super_extra_large">70sp</dimen> <!-- Various Paddings --> <dimen name="padding_very_short">2dp</dimen> <dimen name="padding_short">5dp</dimen> <dimen name="padding_medium">7dp</dimen> <dimen name="padding_normal">10dp</dimen> <dimen name="padding_long">35dp</dimen> <dimen name="padding_long_gamename">55dp</dimen> <dimen name="padding_extra_long">15dp</dimen> <!-- Various Margins --> <dimen name="margin_very_short">5dp</dimen> <dimen name="margin_med_short">5dp</dimen> <dimen name="margin_short">10dp</dimen> <dimen name="margin_meium">15dp</dimen> <dimen name="margin_short_player_review">10dp</dimen> <dimen name="margin_meium_player_review">15dp</dimen> <dimen name="margin_normal">20dp</dimen> <dimen name="margin_long">25dp</dimen> <dimen name="margin_vshape">25dp</dimen> <!-- Various Width --> <dimen name="width_extra_min">120dp</dimen> <dimen name="width_profile_messages_images">70dp</dimen> <dimen name="width_half">240dp</dimen> <dimen name="width_normal">300dp</dimen> <dimen name="width_extra_large">360dp</dimen> <dimen name="width_popup_window">180dp</dimen> <!-- Various Height --> <dimen name="height_very_short_shadow">1dp</dimen> <dimen name="height_short">40dp</dimen> <dimen name="width_ListHalf">260dp</dimen> 

-5
Oct. 16 '17 at 10:47 on
source share



All Articles