2016-03-29 30 views
1

olduğunu. Ancak, bu Etkinlik için XML düzenine gidersem ve android:fitsSystemWindows="true" içine koyarsam, araç çubuğu doğru şekilde yerleştirilir, ancak navbar daha sonra düz bir renk olur. Bunun yerine FrameLayout içine android:fitsSystemWindows="true" koyarsanızSaydam Gezinme Çubuğu düz renk

<?xml version="1.0" encoding="utf-8"?> 
<me.ccrama.redditslide.Views.SidebarLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    android:background="?attr/activity_background"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <View 
      android:id="@+id/anchor" 
      android:layout_width="1dp" 
      android:layout_marginTop="4dp" 
      android:layout_marginRight="3dp" 

      android:layout_gravity="top|right" 
      android:layout_height="1dp" /> 

     <me.ccrama.redditslide.Views.ToggleSwipeViewPager 
      android:id="@+id/content_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/header" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:minHeight="56dp" 
       android:layout_height="?android:attr/actionBarSize" 
       android:theme="@style/ActionBarCompat" 
       android:title="@string/app_name" /> 

      <ViewStub 
       android:id="@+id/stub_tabs" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:inflatedId="@+id/sliding_tabs" 
       android:layout="@layout/activity_overview_tabs" /> 

     </android.support.design.widget.AppBarLayout> 


    </FrameLayout> 

    <ListView 
     android:id="@+id/drawerlistview" 
     android:layout_width="300dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="?attr/card_background" 
     android:orientation="vertical" /> 

    <include 
     layout="@layout/subinfo" 
     android:layout_width="300dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="end" /> 

</me.ccrama.redditslide.Views.SidebarLayout> 

aynı davranış (renkli navbar) gerçekleşir: Burada

düzenidir. Aşağıdaki ilk resim, araç çubuğu düzeninin berbat olduğu ve ikinci telefonun navbarın yarı saydam olmadığı zaman olmasıdır. etkinlik tema olarak aşağıda

enter image description here

enter image description here

+0

GetWindow() setStatusBarColor (Color.TRANSPARENT) ; –

+0

ama durum çubuğunu renklendirirsem ne olur? Ben onu kırmızıya ayarladım. – Nxt3

+0

Anlamı nedir? –

cevap

1

Kullanım teması:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

Ve getNavigationBarColor (Color.TRANSPARENT) kullanın;

WindowManager

ebeveyn tema olarak veya bu temalardan biri arasında, set
  /** 
    * Flag indicating that this Window is responsible for drawing the background for the 
    * system bars. If set, the system bars are drawn with a transparent background and the 
    * corresponding areas in this window are filled with the colors specified in 
    * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}. 
    */ 
    public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000; 


    /** 
    * Window flag: request a translucent status bar with minimal system-provided 
    * background protection. 
    * 
    * <p>This flag can be controlled in your theme through the 
    * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute 
    * is automatically set for you in the standard translucent decor themes 
    * such as 
    * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 
    * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 
    * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 
    * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 
    * 
    * <p>When this flag is enabled for a window, it automatically sets 
    * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 
    * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p> 
    */ 
    public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000; 

Pencere

/** 
* Sets the color of the status bar to {@code color}. 
* 
* For this to take effect, 
* the window must be drawing the system bar backgrounds with 
* {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and 
* {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set. 
* 
* If {@code color} is not opaque, consider setting 
* {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 
* {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}. 
* <p> 
* The transitionName for the view background will be "android:status:background". 
* </p> 
*/ 
public abstract void setStatusBarColor(@ColorInt int color); 
+0

Üzgünüm - ne? "Kaldır" dedin mi? Ayrıca, durum çubuğunun şeffaf olmasını istemiyorum - SADECE navbar. – Nxt3

+0

Yukarıdaki kod I'yi kaldırmanız gerektiği anlamına gelir. Lütfen tema kodunuzu belirtin. –

+0

Bu kodun hiçbir yerinde yok. Tüm ilgili kodumu, navbar yarı saydamını ayarladığım için yayınladım. – Nxt3

0

Eğer özel bir tema oluşturuyorsanız doc

itibaren windowTranslucentNavigation ve windowTranslucentStatus stili pr temanızdaki performanslar.

Yani 19+ tema altında ama Api için kullanabilirsiniz:

değerleri

<style name="Theme.DesignDemo" parent="Base.Theme.DesignDemo"> 
</style> 

<style name="Base.Theme.DesignDemo" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="colorPrimary">#673AB7</item> 
    <item name="colorPrimaryDark">#512DA8</item> 
    <item name="colorAccent">#FF4081</item> 
    <item name="android:windowTranslucentNavigation">true</item> 
</style> 

değerleri-21:.

<style name="Theme.DesignDemo" parent="Base.Theme.DesignDemo"> 
     <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
     <item name="android:statusBarColor">@android:color/transparent</item> 
    </style> 
+0

Yarı saydamlığı ayarlamak için hala Java bölümünü yapmalı mıyım? Zaten önerdiğin şeyi denedim ve işe yaramadı. – Nxt3

+0

Ben bayrak olmadan lolipop denedim ve işe yaradı, senin sorunun ne olduğunu bilmiyorum, bir deneyin. –

+0

Tüm stilleri ekledim –

İlgili konular