問題:1:
從一個全屏界面跳轉到正常的界面時,頂部會被狀態欄覆蓋住,會延遲1秒恢復正常。
解決方案:
在頁面進行跳轉之前(也就是在全屏的界面),加上以下代碼:
/**解決進入首頁時 上部分顯示半個問題*/
WindowManager.LayoutParams attr = getWindow().getAttributes();
attr.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attr);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Intent intent.setClass(this, MainActivity.class);
startActivity(intent);
finish();
問題2:
在anroid 5x及以上 在頁面跳轉時會出現 狀態欄的背景顏色是系統默認的淺灰色
在頁面設置樣式裏增加:
<item name="android:windowTranslucentStatus">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
解析:兩種全屏flage的區別:
(1)不設置
Activity窗口不全屏,狀態欄顯示。
(2)getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Activity窗口全屏,狀態欄不顯示。
(3)getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Activity窗口全屏,且狀態欄顯示。與不設置的區別是Activity的內容是佔滿整個屏幕的,但頂部有部分區域內容是被狀態欄覆蓋的。