Tomi
Tomi

Reputation: 3560

Can I make reference for whole resource folder?

I would like to support many different screen types with the drawable resources. But I can use some drawables with the same size on more screens.

For example: -xxhdpi-normal and -mdpi-xlarge could use the same sized drawable image I don't wan't to make 2 folders (drawables-xxhdpi-normal and drawables-mdpi-xlarge), because then the .apk will be bigger.

I know that if I just put simply every drawable resource into drawables folder with different names. Then I can make the layout for every screen. It is a lot of work but makes a smaller .apk I know that it is easier to maintaine my code if I use refs.xml instead of the differnet layout.xml-s (about refs.xml: http://blog.vogella.com/2013/08/13/using-xml-layout-references-in-android/)

 <?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="layout" name="activity_main">@layout/activity_second</item>
</resources>

But in this case I will still have a lot of work with the resource naming, and I can't use tools like (cut and slice me - photoshop plug-in that exports drawables for different dpi-s)

Is there a way, I can just say to the system: If the device is -mdpi-xlarge use the drawables-xxdpi folder to make the layout?

Upvotes: 1

Views: 291

Answers (1)

miv
miv

Reputation: 349

the system use automatically the resource folder (when avalable) closest to your resolution or one scale and appear best

for example

if you use only xxxxdpi it will alway down scale them , so single folder and quite decent image quality

if you want to use different assets for some resolutions just override that files in that folder

Upvotes: 1

Related Questions