Get screen width and height in Android

前端 未结 30 3633
野的像风
野的像风 2020-11-22 09:28

How can I get the screen width and height and use this value in:

@Override protected void onMeasure(int widthSpecId, int heightSpecId) {
    Log.e(TAG, \"onM         


        
30条回答
  •  隐瞒了意图╮
    2020-11-22 10:16

    It’s very easy to get in Android:

    int width  = Resources.getSystem().getDisplayMetrics().widthPixels;
    int height = Resources.getSystem().getDisplayMetrics().heightPixels;
    

提交回复
热议问题