如何创建设备特定的布局? [英] How to create device specific layouts?

查看:111
本文介绍了如何创建设备特定的布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个android应用程序.我为平板电脑600x1024dp和720x1280dp创建了 layout-sw600dp layout-sw720dp 布局文件夹以及 layout 文件夹我使用三星galexy标签和大小为720x1280的仿真器对它们进行了测试,但始终会从布局文件夹中获取布局.为什么会发生这种情况,即使这些布局是特定于设备的?

I have an android application.I created layout-sw600dp and layout-sw720dp layout folders for tablets 600x1024dp and 720x1280dp along with layout folder for other phones.I am tested these by using samsung galexy tab and emulator of size 720x1280.But it always takes the layout from layout folder. Why this happen even these layouts are device specific?

如何为平板电脑创建特定的布局.

How to create a layout specific for tablets.

预先感谢

推荐答案

当我们使用setContentView()加载活动布局时,我们可以检查BUILD模型,然后在此基础上给出一个布局..

when we loading the activity layout using setContentView () , we can do a check the BUILD model and based on that we a give a laod a layout..

例如:

该代码看起来与此类似.

The code looks somethink simialr to this..

if(android.os.Build.MODEL.equals("XXX"))

if(android.os.Build.MODEL.equals("XXX"))

setContentView(R.layout.x);

setContentView(R.layout.x);

其他

setContentView(R.layout.y);

setContentView(R.layout.y);

如果需要任何帮助,请告诉我.

Kindly let me know incase if you need any help.

这篇关于如何创建设备特定的布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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