How to get screen width and height

后端 未结 14 1057
梦如初夏
梦如初夏 2020-12-12 20:31

I tried to use following code to get screen width and height in android app development:

Display display = getWindowManager().getDefaultDisplay(); 
int scree         


        
14条回答
  •  攒了一身酷
    2020-12-12 20:55

    Display display = getActivity().getWindowManager().getDefaultDisplay(); 
    int screenWidth = display.getWidth();
    int screenHeight = display.getHeight();
    Log.d("Tag", "Getting Width >> " + screenWidth);
    Log.d("Tag", "Getting Height >> " + screenHeight);
    

    This worked properly in my application

提交回复
热议问题