Android devices with different heights accept the same layout folder

I have a Micromax AQ5000 with a screen resolution of 1280 * 720 pixels and a Motorola Moto G XT1033 with a resolution of 720 x 1280 pixels. I have a layout folder called layout-sw360dp that I developed for devices like Samsung s4, s3, Micromax canvas, etc., but this Motorola device also uses the same layout, and this creates images that appear distorted in him.

How to create a folder for a small device (Moto g) I tried layout-xhdpi, but it doesn’t work, as I can call a layout with height and width.

+5
source share
1 answer

, , - , , , . .

, res,

layout-hdpi

layout-mdpi

layout-xhdpi

layout-xxhdpi

layout-w320dp-h408dp

layout-w480dp-h800dp

layout-w480dp-h854dp

layout-w720dp-h1280dp

layout-w1080dp-h1920dp

,   -w1440dp-h2560dp

"dip", , ,

<ImageView
            android:id="@+id/avtar_animation_11"
            android:layout_width="45dip"
            android:layout_height="45dip"
            android:src="@drawable/avtar011"/>

, "dp" , Android , . , res Android, .

enter image description here

values-hdpi, values-mdpi, values-ldpi, values-xhdpi, values-xxhdpi

dimens.xml

<dimen name="image_view_width">28dp</dimen>
<dimen name="image_view_height">28dp</dimen>

, "dp" dip android, , . image_view_width image_view_height , dimens.xml. , dp , , .

 <ImageView
        android:id="@+id/avtar_animation_11"
        android:layout_width="@dimen/image_view_width"
        android:layout_height="@dimen/image_view_height"
        android:src="@drawable/avtar011"/>

, android dimens.xml, , , Voila rock

+16

Source: https://habr.com/ru/post/1620678/


All Articles