6

我想讓我的活動全屏幕狀態欄上喜歡這幅畫它的上面:Android的 - 在它上面製作活動全屏幕狀態欄

enter image description here

我已經使用這個代碼manifestactivity標籤:

'android:theme="@style/Theme.AppCompat.Light.NoActionBar"' 

不過我的看法不從狀態欄&開始它看起來像這樣:

enter image description here

如何讓我的activity看起來像第一個?

+1

化妝狀態欄顏色透明,並添加fitsystemwindow =真實圖像和頂面佈置 –

+0

@Utshaw,你有一個解決方案。如果是的話請幫助我。需要相同的實現 –

回答

12

styles.xml

<item name="android:windowTranslucentStatus">true</item> 
<item name="android:windowTranslucentNavigation">true</item> 

這些你基礎應用主題添加和以下屬性添加到您的父母佈局:

android:fitsSystemWindows=」true」 

希望這有助於。

+0

只適用於API 19及以上 – Shadow

+0

,並會影響每個活動 – toshkinl

+1

'android:fitsSystemWindows =「true」',這對我不起作用。 – AJit

-1

將這個代碼在活動的onCreate這將隱藏狀態欄

View decorView = getWindow().getDecorView(); 
// Hide the status bar. 
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 
decorView.setSystemUiVisibility(uiOptions); 
// Remember that you should never show the action bar if the 
// status bar is hidden, so hide that too if necessary. 
ActionBar actionBar = getActionBar(); 
actionBar.hide(); 
0

嘗試像這樣

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 

希望這個人會幫

2

如果你不希望你的「半透明導航」透明的,這裏是代碼只是讓透明狀態欄

在你的主題:

<item name="android:statusBarColor">@android:color/transparent</item> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:windowTranslucentStatus">true</item> 

在你活動的onCreate:

Window window = getWindow(); 
WindowManager.LayoutParams winParams = window.getAttributes(); 
winParams.flags &= ~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; 
window.setAttributes(winParams); 
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); 
+2

節省了我的時間,正在尋找這個小時。 +1 –

1

您可以在onCreate後使用此代碼

setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
     if (getSupportActionBar() != null) { 
      getSupportActionBar().hide(); 
     } 

您的活動將是fullscrean與狀態欄:)

+0

這是最好的答案,謝謝Mostafa。 – Ayoub