开发者

How to retrieve height of application header?

Is there a way to retrieve the height (in pixels) taken by the application title and the top bar (the one containing the clock, signal informati开发者_StackOverflowon etc...)

Thanks


Create a sample android program. Android would have created a Linearlayout by default in your main.xml for you. Provide an ID to that layout and use it

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜