Decoding Resource Directory Names
Our app has a bunch of resource directories. Some have simple names, like drawable/
and layout/
. Others have suffixes, like drawable-v24/
and mipmap-hdpi/
.
The initial segment of the directory name — or the whole name for those that lack suffixes — usually indicates the type of the resource. There are many resource types in Android, and we will explore a few of them in this chapter. The exception is the values/
directory, which can contain a variety of smaller resource types, not just one “values” type.
The suffixes represent “resource sets”, and they indicate that this directory contains resources of a particular type that should only be used in certain scenarios. We call these scenarios “configurations”; the suffixes indicate what configurations those resources are used for.
For example:
-
drawable/
has resources that are good for any configuration, butdrawable-v24/
has resources that are only going to be used on API Level 24 and higher devices (i.e., Android 7.0 and higher) -
mipmap-anydpi-v26/
has resources that are good for any screen density, but they will only be used on API Level 26 and higher devices -
mipmap-mdpi/
has resources that are designed around “medium density” screens, where the density is around 160dpi (dpi = dots per inch)
We will explore these rules more later in the book, as they get fairly complex fairly quickly.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.