Android资源中已有多dpi drawable文件夹,仍需普通drawable吗?其图片尺寸要求?
Hey fellow Android dev! Let's tackle your two drawable folder questions one by one:
问题1:已有hdpi/mdpi/xhdpi/xxhdpi/xxxhdpi这些drawable文件夹,还需要保留普通drawable吗?
Short answer: It's not strictly required, but it's often a good idea—here's why:
- If you use vector resources (like
vectoricons,shapedrawables, or other XML-based graphics), the regulardrawablefolder is the perfect home for them. Vector assets scale losslessly across all screen densities, so you don't need duplicate copies in dpi-specific folders. - If you've already covered all bitmap assets (PNGs/JPGs) in the dpi-specific folders, you don't have to put bitmaps in the regular
drawablefolder. But it can serve as a fallback: if for some reason a density-specific asset is missing, the system will pull fromdrawableinstead. For this fallback, just use the mdpi-sized version of your bitmaps. - For super old Android versions (API 10 and below), the regular
drawableacts as the default density bucket, but this is rarely a concern these days since most devices run newer OS versions.
问题2:普通drawable文件夹该放多大的图片?是否需要保留?
First, the regular drawable folder is treated as the mdpi (160dpi) density bucket by default. So if you're putting bitmap assets here, use the base mdpi size—for example, a standard launcher icon would be 48x48px here, with scaled versions (72x72 for hdpi, 96x96 for xhdpi, etc.) in the dpi-specific folders.
As for whether to keep it:
- If your project relies heavily on vector assets or XML drawables (like selectors, layer-lists), keep the
drawablefolder—it's the standard place for these universal assets. - If all your bitmaps are fully covered in dpi-specific folders, you can skip it. But keeping it around for fallback assets or universal XML drawables doesn't hurt, and it keeps your resource structure organized.
内容的提问来源于stack exchange,提问作者Khar Fai Mak
相关产品推荐
相关产品推荐

