簡體   English   中英

使用Robotium測試Android設備的分辨率

[英]Testing an Android device resolution using Robotium

有沒有一種方法可以測試android設備的分辨率?

在任何測試功能中,您都可以編寫以下代碼:

    Activity ACT = getActivity();


    Display display = ACT.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

或API <13

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth(); 
int height = display.getHeight(); 

希望對您有幫助:[如果您計划為手機/平板電腦運行相同的測試代碼]

Configuration mConfig = mContext.getResources().getConfiguration();

// checking for XLarge screen ...U can also check for Large screen similarly    
if ((mConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_XLARGE) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {  

        Log.i("TABLET MODE");
        // Do ur actions for Tablet
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM