2017-08-26 86 views
0

我的麻煩是我不能使一個透明的狀態欄,只有超級地圖。 這裏是超級製作:enter image description here如何透明狀態欄無需更改NaviBar android

我嘗試使用

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 
     Window w = getWindow(); // in Activity's onCreate() for instance 
     w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); 
    } 

但它使透明的所有狀態和navibar。我不想這樣。只是狀態欄。你能幫我嗎,夥計?只要按下任何評論事建議我

我的代碼:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    style="@style/AppThemeMap" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:openDrawer="start"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <include 
      layout="@layout/app_bar_maps" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </RelativeLayout> 
    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     android:visibility="visible" 
     app:headerLayout="@layout/nav_header_maps" 
     app:itemTextAppearance="@style/NavigationDrawerStyle" 
     app:menu="@menu/activity_maps_drawer" 
     app:theme="@style/NavigationDrawerStyle"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:orientation="vertical"> 
      <goixeom.com.CustomTextView 
       android:id="@+id/term" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:paddingBottom="@dimen/size_margin_nav" 
       android:layout_marginLeft="72dp" 
       android:text="Quyền riêng tư" 
       android:textStyle="bold" /> 
      <goixeom.com.CustomTextView 
       android:id="@+id/dang_xuat" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:paddingBottom="@dimen/size_margin_nav" 
       android:layout_marginLeft="72dp" 
       android:text="Điều khoản" 
       android:textStyle="bold" /> 
     </LinearLayout> 
    </android.support.design.widget.NavigationView> 
</android.support.v4.widget.DrawerLayout> 

我的應用程序截圖: enter image description here 謝謝!

+0

只需添加這行做你想做的所有狀態欄在您的應用中保持透明? –

+0

是的。所有狀態欄,但不影響Navibar。 –

+0

查看我的回答下面 –

回答

0

只是這一行添加到您的基礎應用主題

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

或編程

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 
} 
+0

試試@sibin davis,它會工作 –

0

在活動

getWindow().getDecorView().setSystemUiVisibility(
       View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
         | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); 

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
      getWindow().setStatusBarColor(Color.TRANSPARENT); 
     } 
+0

好吧,它只會使狀態欄顏色變灰。我的地圖不適合狀態欄,顏色狀態不透明。 我在我的問題中添加了源代碼。 –

+0

你是否已經刪除了風格 –

+0

是的,但它不起作用 –