by using the code:
DisplayMetrics dm = getResources().getDisplayMetrics();
int screenWidth = dm.widthPixels;
int screenHeight = dm.heightPixels;
Log.e(TAG, "W = " + dm.widthPixels + ", H = " + dm.heightPixels);
get the width and height of the screen. On the phone I tested, screenWidth = 1440 , screenHeight = 2400 :
View
layout_width
layout_height
match_parent
:
onDraw
View width height:
:
I would like to ask you why and how to solve this inconsistency problem?