Issue
I know the discussion about this is available everywhere and I myself have worked with these folders, but still after reading them I recently I had a big confusion regarding how to arrange images in drawable folders -
Look at this XML File -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/wallpaper_chapter_selection"
tools:context="com.greenloop.joindotsandpaint.ChapterSelection">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/img2"
android:padding="20dp" />
<RelativeLayout
Let's consider 2 phones regarding this Landscape Mode -
Nexus 10 - 2560 px * 1600px xhdpi
Nexus 5 - 1920px * 1080px xxhdpi
In the case of Nexus 10 - Image size will be 1600px (height) And in the case of Nexus 5 - Image size will be 1080px
Image size required by Nexus 10 will be greater than that required by Nexus 5, But nexus 10 will take image from the xhdpi folder (smaller image size) as it is xhdpi and nexus 5 will take image from xxhdpi folder.
So how should I work around this. I have lots of similar layouts in which I am facing a similar problem.
Solution
The drawable-hdpi
, drawable-xhdpi
, drawable-xxhdpi
etc. specifies only the dpi dimension and devices of all sizes are going to get resources from the same folder as long as they have the same dpi specifications. To add the screen size dimension you can add large
(for devices 7" and around), xlarge
(for devices 10" and around) etc. to this. For example you can have a drawable-xlarge-xhdpi
to force the Nexus 10" to get a particular resource from this folder. Or your can have only drawable-xlarge
and this way all the 10" devices will pull the resources from this folder, no matter what their dpi is.
Basically the one-catch-all is the drawable
folder and you overwrite on a case by case basis with the values from drawable-*-*-etc
. folders.
Answered By - N.T.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.