在运行时以编程方式查找最匹配的资源
是否可以在运行时以编程方式找到最匹配的资源?
例如,我有一些设备的屏幕属性与布局正常-mdpi 完美匹配。我如何在运行时读取该规范?例如,对于我的屏幕,结果应该是正常屏幕尺寸,对于密度 mdpi 来说,结果应该是完美匹配。
Is it possible to find the best-matching resource Programmatically at run-time ?
For example I have some device that have screen properties that makes perfect match for layout-normal-mdpi. How can I, at run time, read that that specification ? For example for my screen the result should be normal screen size and for the density mdpi as perfect match.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该能够通过创建合格的资源文件夹自动完成。如果您为不同的条件创建多个资源文件夹,设备将读取您的条件并为其选择最佳的资源版本。
参考: http://developer.android.com/guide/topics/resources /providing-resources.html
This should be able to be done automatically by creating qualified resource folders. If you create multiple resource folders for different conditions the device will read your conditions and choose the best version of the resource for it.
Reference: http://developer.android.com/guide/topics/resources/providing-resources.html