Reputation: 24099
I just want to clarify, with the res folders in android, with lower resolution devices, they automatically get the same named asset from the ldpi folder? This is so I can make different assets for smaller screens?
Do I need to have assets in all 4 folders (ldpi - xhdpi) for it to work on all sized devices? Or can I just have assets in one folder if the assets are all the same for all devices?
And what if my assets are only different for low res devices, do I need to mirror the contents of each of the other folders so they all have the same assets in?
Upvotes: 0
Views: 850
Reputation: 5980
Lets break your question into three seperate questions.
I just want to clarify, with the res folders in android, with lower resolution devices, they automatically get the same named asset from the ldpi folder? This is so I can make different assets for smaller screens?
Quite simply, yes. That's what the system is for. As long as you use assets with the same name, Android will automatically pick the one that works best for your device, depending on the dpi of the screen.
Do I need to have assets in all 4 folders (ldpi - xhdpi) for it to work on all sized devices? Or can I just have assets in one folder if the assets are all the same for all devices?
You do not need the assets in all folders to have it work on all devices. However, if you want it work well, you will need assets in all folders, all with their own dimensions depending on the folder. If you only use one folder with one size of assets, it will still work. Your assets will just get scaled by Android itself which can cause some assets to look really ugly on some higher/lower dpi devices. Let alone the fact that the scaling can cause your entire layout to mess up.
And what if my assets are only different for low res devices, do I need to mirror the contents of each of the other folders so they all have the same assets in?
By "only different for low res devices", do you mean that the entire asset is different? For instance a blue image instead of a red one? If so you would still need to use the same name as the assets in the other folders. The actual content can be different, the OS only checks the names when grabbing the assets.
For more info about how to support multiple screen sizes, give this guide a try:
http://developer.android.com/guide/practices/screens_support.html
Upvotes: 0
Reputation: 134714
I would suggest reading this article thoroughly to get an understanding of exactly how it works, but basically, it will find the closest matching size resource that is available, so no, you don't need to mirror across all folders necessarily.
From the qualifiers section particularly, this quote explains it well.
Be aware that, when the Android system picks which resources to use at runtime, it uses certain logic to determing the "best matching" resources. That is, the qualifiers you use don't have to exactly match the current screen configuration in all cases in order for the system to use them. Specifically, when selecting resources based on the size qualifiers, the system will use resources designed for a screen smaller than the current screen if there are no resources that better match (for example, a large-size screen will use normal-size screen resources if necessary). However, if the only available resources are larger than the current screen, the system will not use them and your application will crash if no other resources match the device configuration (for example, if all layout resources are tagged with the xlarge qualifier, but the device is a normal-size screen). For more information about how the system selects resources, read How Android Finds the Best-matching Resource.
Upvotes: 1