Display.getSize vs Dispaly.getWidth

android

Solution

Use Display Metrics

DisplayMetrics display = this.getResources().getDisplayMetrics();

        int width = display.widthPixels;
        int height = display.heightPixels;

Problem

I have a little issue here... I want to get the size of the display, which I can get either by calling the deprecated `Display.getWidth` / `.getHeight` or I can use `Display.getSize`... But heres my problem... I don't want to use deprecated code, so that leaves me with `Display.getSize`... But that requires `API 13` and I would like my min-API to be 8.... What should I do? Is there another option? ``` Point size = new Point(); display.getSize(size); width = size.x; height = size.y; ``` vs ``` width = display.getWidth(); height = display.getHeight(); ```

Original source

Related problems