开发者

How to retrieve height of application header?

开发者 https://www.devze.com 2023-01-23 00:17 出处:网络
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...)

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

精彩评论

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