如何獲取活動標題欄的大小和系統欄的大小?Android標題欄大小
2
A
回答
1
我這樣做,用我的根佈局,問題是,當他們被第一次跑,你不能獲得你的onCreate /在onStart /方法的onResume此信息(寬度和高度)。
之後的任何時刻,大小可從根佈局(LinearLayout中/ FrameLayout裏/ TableLayout /等),在我的情況我是用檢索的FrameLayout:
FrameLayout f = (FrameLayout) findViewById(R.id.layout_root);
Log.d(TAG, "width " + f.getMeasuredWidth());
Log.d(TAG, "height " + f.getMeasuredHeight());
或:
FrameLayout f = (FrameLayout) findViewById(R.id.layout_root);
Log.d(TAG, "width " + f.getRight());
Log.d(TAG, "height " + f.getBottom());
既然已經有活動的高度,要知道系統欄的高度只是從活動的高度減去全屏高度。
如何讓屏幕的高度在這裏解釋說:從這裏編輯 Get screen dimensions in pixels
-------------------------- ------------------------------
我找到一種方式來獲得對onCreted方法這個信息,但只有當你有更多的活動。就我的情況而言,我有一項主要活動稱爲第二項活動。
在main_activity之前我所說的second_activity,由新Itent,我可以添加爲second_activity額外的信息。以下是你需要的第一個活動代碼:
Intent i = new Intent(this, SecondActivity.class);
i.putExtra("width", f.getMeasuredWidth());
i.putExtra("height", f.getMeasuredHeight());
startActivity(i);
之後,在第二次的活動,你可以檢索你的第二個活動的onCreate方法這個信息這樣做:
int width = getIntent().getExtras().getInt("width");
int height = getIntent().getExtras().getInt("height");
相關問題
- 1. Android標題欄圖標大小
- 2. Android:增加標題欄大小?
- 3. 如何在Android中動態設置標題欄大小和標題大小
- 4. 導航欄標題字體大小
- 5. 操作欄圖標大小
- 6. 如何增加標籤欄標題的字體大小?
- 7. Windows中Adobe Air中的標題欄圖標大小錯誤
- 8. Jqgrid - 更大的標題欄
- 9. 標題大小問題
- 10. 刪除標題欄(Android)
- 11. Android中的標題欄
- 12. Android - 自定義標題欄
- 13. Android的標題欄去除
- 14. 自定義標題欄android
- 15. 的Android刪除標題欄
- 16. Phonegap Android顯示標題欄
- 17. Android PreferenceScreen標題欄刪除
- 18. Android Listview隱藏標題欄
- 19. 移除Android的標題欄
- 20. Android靜態標題欄
- 21. 的Android 4.2標題欄在操作欄
- 22. 改變標題文本的顏色和大小菜單android動作欄
- 23. android操作欄按鈕大小調整問題
- 24. Android自定義評分欄圖片大小問題
- 25. 如何在動態導航欄中調整標題大小
- 26. Swift 3:標籤欄控制器圖像大小問題
- 27. 如何獲取Winforms表單標題欄高度的大小?
- 28. 如何更改操作欄上標題文本的大小?
- 29. 與標籤欄應用截圖大小的問題
- 30. 自動調整大小的導航欄標題錯位