我可以以编程方式选择Android布局文件夹吗? [英] Can I programmatically choose the Android layout folder?

查看:85
本文介绍了我可以以编程方式选择Android布局文件夹吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Android应用程序,该应用程序使用不同的布局文件夹(即大号,xlarge等)根据屏幕尺寸调整大小.

I'm building an Android app that resizes based on the screen size using different layout folders (i.e. large, xlarge, etc.).

唯一的问题是,我希望为用户提供一种在小屏幕布局和大屏幕布局之间切换的方式,以防用户拥有无法识别xlarge标签的蜂窝状平板电脑,或者设备更接近手机尺寸,但仍然足够大,以至于用户希望使用平板电脑的布局.

The only problem is that I want to provide a way for users to switch between the small and large screen layouts, in case they have a pre-honeycomb tablet that doesn't recognize the xlarge tag, or the device is closer to phone size but still big enough that the user wants to use the tablet layouts.

有没有一种方法可以创建一个按钮来切换布局文件夹?我仍然想使用基于屏幕大小的自动文件夹选择,我还想强制应用程序使用一个文件夹或另一个文件夹.

Is there a way that I can create a button to switch layout folders? I still want to use the automatic folder selection based on screen size, I just ALSO want to be able to force the app to use one folder or the other.

有可能吗?

推荐答案

android小组鼓励您将资源限定符用于任何种类的多设备支持.例如

The android team encourage you to use the resource qualifiers for any kind of multiple devices support-ion. For example

布局小-适用于小屏幕设备 低密度设备的layout-ldpi layout-en for locales ...

layout-small for devices with small screens layout-ldpi for devices with low density layout-en for locales...

阅读它将对您有很大帮助

read this it will help you a lot

但是通常不,没有编程方法可以做到这一点,也许有一些解决方法,但我不鼓励这样做.

But generally NO, there is no programmatic way to do this, maybe there are some workarounds but I do not encourage to do that.

也许您还需要查看片段设计,以了解针对不同设备(例如平板电脑和手机)的gui的开发...

Also maybe you need to see the fragments design to understand the development of gui for different devices like tablets and phones...

这篇关于我可以以编程方式选择Android布局文件夹吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆