如何划分为480×800,并在Android的480 * 854的屏幕分辨率布局? [英] How to differentiate layout for 480 * 800 and 480 * 854 screen resolutions in android?

查看:333
本文介绍了如何划分为480×800,并在Android的480 * 854的屏幕分辨率布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我需要确保UI组件将被放置在适当的位置在所有的屏幕分辨率设备的应用之一。我已经通过Android开发者网站上的支持多种屏幕分辨率教程了。在此基础上,似乎我可能要创建单独的布局文件小,正常和大屏幕设备。现在,这个问题在这是,即使在大尺寸的屏幕有不同的分辨率,例如480×800和480×854,在屏幕的组件被略微错位的。我已经设置上边距为100浸那么对于480 * 800看起来正常,但480 * 854是稍微放错了地方。

In one of the application I need to make sure that UI components will be placed at proper position in all the screen resolution devices. I have gone through the support multiple screen resolutions tutorial on android developer site. Based on that it seems I may have to create separate layout files for small, normal and large screen devices. Now, the issue in this is that even in large screens there are different resolutions such as 480 * 800 and 480 * 854. In the screen the components gets misplaced slightly. I have set top margin as 100 dip then for 480 * 800 it appears properly but for 480 * 854 it is misplaced slightly.

有人可以让我知道现在该怎么处理呢?

Can someone let me know how to handle this now?

推荐答案

这两个分辨率的布局长下考虑的,所以你必须要设置布局根据设备的高度和宽度手动

both the resolutions are considered under the layout-long, so you have to set the layout as per the device's height and width manually.

按我的看法,这是最好的解决方案。我申请了相同的解决方案,我的应用程序。

As per my view this is the best solution . I applied the same solution for my application .

        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        height = dm.heightPixels;
        width = dm.widthPixels;

        if (height == 854 || width == 480) 
        {
              // Your view 
        }
        else
        {
              // Your VIew
        }

您必须检查的onCreate上述条件(acivity ..

You have to check the above condition in onCreate() method of acivity..

这篇关于如何划分为480×800,并在Android的480 * 854的屏幕分辨率布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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