问题
I saved some images directly to the drawable folder. These, Android Studio recognizes normally. But the images saved in the mhdpi, hdpi, xhdpi, xxhdpi and xxxhdpi folders the code does not recognize and shows an error. Does anyone know what's going on? Thanks!
回答1:
Try making new drawable folders for putting images after right clicking res folder and name folders like this
drawable-hdpi
drawable-mdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
Drag and drop image with same name according to their dimensions. The android takes drawable folder as one entity, picks up the best suited image and shows it on different resolution phones.
回答2:
The whole point of the drawable folders is that Android can decide which density it should take depending on the screen resolution.
A low resolution device will e.g. the drawable from the drawable-ldpi folder and a very high resolution device will take the drawable from the drawable-xxxhdpi folder.
In your code you always reference the drawable as
R.drawable.yourdrawablename
来源:https://stackoverflow.com/questions/42363211/android-studio-doesnt-recognize-images-in-hdpi-folder