سؤال

هل هناك طريقة لاسترداد الارتفاع (بالبكسل) الذي يتم تناوله بواسطة عنوان الطلب والشريط العلوي (واحد يحتوي على الساعة ومعلومات الإشارة وما إلى ذلك)

شكرًا

هل كانت مفيدة؟

المحلول

إنشاء نموذج Android. كان Android قد أنشأ LineArlayout افتراضيًا في Main.xml لك. قدم معرفًا لهذا التصميم واستخدمه

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top