簡體   English   中英

屏幕寬度和高度Android

[英]Screen Width and Height Android

要設置的minimum-sdk和target-sdk,以便我們可以檢查Android版本,並根據Android版本使用getSizez()getWidth()getHeight() 我目前的最低SDK為8 ,目標為13

我目前正在做的是

    Display display=getWindowManager().getDefaultDisplay();

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD) 
    {
        width=display.getWidth();
        height=display.getHeight();
        // only for android older than gingerbread
    }
    else
    {
        display.getSize(point);
        width=point.x;
        height=point.y;
        Log.I("Width",Integer.toString(width));
        Log.I("Height",Integer.toString(height));
    }

但是它在display.getSize(point)上給出了錯誤。

The method getSize(Point) is undefined for the type Display..

任何形式的幫助將非常感激。

在developer.android.com網站上檢查時,它說display.getSize(point)僅對android 13及更高版本有效,因此我將從

如果(Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD)

如果(Build.VERSION.SDK_INT <13)

暫無
暫無

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

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