有没有办法检索应用程序标题和顶栏(包含时钟、信号信息等的那个)所采用的高度(以像素为单位)
谢谢
创建一个示例 android 程序。默认情况下,Android 会在您的 main.xml 中为您创建一个 Linearlayout。为该布局提供一个 ID 并使用它
final LinearLayout ll1=(LinearLayout)findViewById(R.id.ll1);
ll1.post(new Runnable()
{
public void run()
{
Rect rect= new Rect();
Window window= getWindow(); ll1.getWindowVisibleDisplayFrame(rect);
int statusBarHeight= rect.top;
Log.e("", "ht of sb bar is "+statusBarHeight);
int contentViewTop= window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight= contentViewTop - statusBarHeight;
Log.e("", "ht of title bar is "+titleBarHeight);
}
});
http://andmobidev.blogspot.com/2010/01/getting-height-of-status-and-title-bar.html