窗口小部件布局960×540和854×480 [英] Widget Layout for 960x540 and 854x480

查看:176
本文介绍了窗口小部件布局960×540和854×480的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两种尺寸的从相同的布局文件夹拉。所以...我想知道我怎么可以创建窗口小部件,看起来不错的两者兼而有之?我重视的屏幕截图,显示在两个显示器被拉动相同的资源。

任何想法?


解决方案

 这两种尺寸可供相同布局的文件夹拉。

在Android的是基于设备的密度不同的屏幕配置为例如:

(LDPI)的屏幕(〜120DPI)。

(MDPI)屏幕(〜160dpi)。

(华电国际)屏幕(〜240dpi)。

(xhdpi)屏幕(〜320dpi)。

两者 960×540和854×480 华电国际布局下降,所以你对于单得到同样的布局。

要解决这个问题,让这两个规范倾向于UI创建单独的XML为内外 HDPI布局。对于如:960_540.xml和854_480.xml

在活动检查设备的屏幕大小,以便设定相应的内容查看

您可以使用显示度量低于code获取屏幕尺寸:

 显示显示= getWindowManager()getDefaultDisplay()。
    屏幕宽度= display.getWidth();
    screenHeight = display.getHeight();
    DM =新DisplayMetrics();
    。getWindowManager()getDefaultDisplay()getMetrics(DM)。
    串str_ScreenSize = dm.widthPixels +×+ dm.heightPixels;
    str_ScreenSize =DD+×+ dm.heightPixels;    如果(screenHeight == 854&安培;屏幕宽度== 480){
        的setContentView(R.layout.854_480);
    }
    否则,如果(screenHeight == 960安培;&安培;屏幕宽度== 540){
        的setContentView(R.layout.960_540);
    }

Both of these sizes pull from the same layout folder. So...I am wondering how I can create widget that looks good on both? I have attached screen shots to show the 2 displays that are pulling the same resources.

Any ideas?

解决方案

Both of these sizes pull from the same layout folder.

In Android the layout was chosen based on the density of the Devices Different Screen Configuration for eg:

(ldpi) screens (~120dpi).

(mdpi) screens (~160dpi).

(hdpi) screens (~240dpi).

(xhdpi) screens (~320dpi).

Both 960x540 and 854x480 falls in hdpi layout , so you are getting same layout for both one.

To solve this issues , to get apt UI for both specification create separate XML for both inside hdpi-layout. for eg: 960_540.xml and 854_480.xml

In Activity check the Screen Size of Device so that set corresponding ContentView

You can get Screen Size using Display Metrics below Code :

    Display display = getWindowManager().getDefaultDisplay(); 
    screenWidth = display.getWidth(); 
    screenHeight = display.getHeight();
    dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    String str_ScreenSize = dm.widthPixels + " x " + dm.heightPixels;
    str_ScreenSize = "dd" + " x " + dm.heightPixels;

    if(screenHeight==854 & screenwidth==480){
        setContentView(R.layout.854_480);
    }
    else if(screenHeight==960 && screenwidth==540){
        setContentView(R.layout.960_540);
    }

这篇关于窗口小部件布局960×540和854×480的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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