Android Studio doesn't recognize images in hdpi folder

删除回忆录丶 提交于 2019-12-13 09:48:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!