Get screen width and height in Android

前端 未结 30 4223
野的像风
野的像风 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:25

    Why not

    DisplayMetrics displaymetrics = getResources().getDisplayMetrics();

    then use

    displayMetrics.widthPixels (heightPixels)

提交回复
热议问题