How can I tell in the SDK which resource file was actually used?

I run my application from the SDK right on my phone connected to my computer. Is there a way to determine (using SDK tools) which dpi dpi folder is used to display a specific png file in the application?

Edit: To be clear. I figured out how to get this information using other methods: 1. placing different files under the same name in different dpi folders 2. write w a short piece of code to check it programmatically The real question is: can I get this information directly in the SDK (DDMS or hierarchy viewer)?

+3


source to share


3 answers


You cannot find which folder you are using. But you can find which density to use.

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

      

then you can use metrics.densityDpi to find which DPI is being used. it will be DENSITY_DEFAULT, DENSITY_HIGH, DENSITY_LOW, DENSITY_MEDIUM, etc. you can compare and find out.



If it is DENSITY_HIGH - drawable-hdpi DENSITY_LOW = drawable-ldpi DENSITY_MEDIUM - drawable-mdpi

See the documentation here http://developer.android.com/reference/android/util/DisplayMetrics.html

+3


source


you don't need to know about it. In each drawable * folder you put your resource with the same name and android will choose which drawings should be shown.



0


source


You can try adding another graphic with the same name. This way you can find out which folder your phones are using.

Or programmatically check what type of screen your device is (hdp, mdpi, ldpi) and then the corresponding selectable folder will be used automatically.

0


source







All Articles