android 标题栏的高度

240x320的高度为20px

320x480的高度为25px

480x800的高度为38px

 

不知道为什么我写的测试程序按照网上的说法老是获取不到,以上是我google搜索出来的结果。

以下是我写的获取标题栏高度的代码:

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mainLinear = (LinearLayout)findViewById(R.id.main); setScreenSize(); } public void setScreenSize(){ Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.bottom; View view = getWindow().findViewById(Window.ID_ANDROID_CONTENT); String sss = "top = " + view.getTop() + " bottom = " + view.getBottom(); // int titleBarHeight = contentTop - statusBarHeight; // System.out.println("titleBarHeight = " + titleBarHeight); String ss = sss + "statusBarHeight = " + statusBarHeight; Toast.makeText(this, ss, Toast.LENGTH_LONG).show(); WindowManager manager = this.getWindowManager(); Display display = manager.getDefaultDisplay(); screenWidth = display.getWidth(); screenHeight = display.getHeight(); } 

你可能感兴趣的:(android,String,manager,Google,测试)