本文介绍了最简单的办法知道(编程)的资源文件夹是基于屏幕密度/尺寸使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法确切地知道哪些布局(和其他资源)是由Android期间选择的运行支持多种屏幕时,根据屏幕密度和大小?

Is there a way to know exactly which layout (and other resources) are chosen by Android during runtime based on screen density and size when supporting multiple screens?

我需要知道该文件夹的名称。

I need to know the folder's name.

编辑:

我需要知道该文件夹的名称编程

I need to know the folder's name programmatically.

推荐答案

如果你只是在做这个为了调试的目的是,我建议你做这样的事情:对于您有一个布局/绘制每个预选赛中,有一个值具有相同预选赛文件夹(例如,如果你有一个布局,华电国际,也有价值观,华电国际相匹配)。添加的strings.xml为每个文件夹,并定义字符串:

If you're just doing this for debugging purposes, I'd recommend doing something like this: For each qualifier that you have a layout/drawable for, have a values folder with the same qualifier (e.g. if you have a layout-hdpi, also have a values-hdpi to match). Add a strings.xml for each of these folders, and define a string:

值,华电国际

<string name="folder_name">hdpi</string>

价值观xhdpi

<string name="folder_name">xhdpi</string>

然后,只需解决字符串时,你需要它,它会告诉你选择哪个文件夹。

Then just resolve the string when you need it, and it will tell you which folder was selected.

这篇关于最简单的办法知道(编程)的资源文件夹是基于屏幕密度/尺寸使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 20:40