2016-07-19 2 views
1

Пока я открываю ящик, цвета панели инструментов становятся более темными, чем цвет остальной части экрана.Панель инструментов становится более темной, чем обычно, при открытии выдвижного ящика

Изначально цвет фона панели инструментов белый. Есть идеи, почему это происходит ?

код я использую ниже:

<android.support.v4.widget.DrawerLayout 
android:id="@+id/dl_poll_container" 
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:background="@color/white" 
android:layout_width="match_parent" android:layout_height="match_parent" 
android:fitsSystemWindows="false"> 

<LinearLayout android:id="@+id/ll_toolbar_container" 
    android:orientation="vertical" 
    android:layout_width="match_parent" android:layout_height="wrap_content"> 

    <android.support.v7.widget.Toolbar android:id="@+id/tb_poll_toolbar" 
     android:gravity="center" 
     android:layout_width="match_parent" android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/tv_poll_toolbar_title" 
      android:gravity="center" android:layout_gravity="center" 
      android:textSize="@dimen/text_size_xxxlarge" android:fontFamily="sans-serif" 
      android:textColor="@color/black" tools:text="My Title" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" /> 

    </android.support.v7.widget.Toolbar> 

</LinearLayout> 

<FrameLayout android:background="@color/white" 
    android:layout_marginTop="?attr/actionBarSize" 
    android:layout_width="match_parent" android:layout_height="wrap_content"> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/vp_poll_viewpager" 
     android:background="@color/white" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="horizontal" android:layout_gravity="center_horizontal" 
     android:layout_marginTop="48dp" 
     android:background="@drawable/background_line" 
     android:layout_width="144dp" android:layout_height="wrap_content"> 

     <FrameLayout android:layout_width="36dp" android:layout_height="36dp" 
      android:layout_alignParentLeft="true"> 

      <ImageView 
       android:id="@+id/pager_img_one" 
       android:layout_width="36dp" android:layout_height="36dp" 
       android:scaleType="centerInside" 
       app:srcCompat="@drawable/ic_active_nav" /> 

      <TextView android:id="@+id/tv_poll_one" 
       android:textStyle="bold" 
       android:text="1" android:gravity="center" 
       android:textColor="@color/white" 
       android:layout_width="36dp" android:layout_height="36dp" /> 

     </FrameLayout> 

     <FrameLayout android:layout_width="36dp" android:layout_height="36dp" 
      android:layout_centerInParent="true"> 

      <ImageView 
       android:id="@+id/pager_img_two" 
       android:layout_width="36dp" android:layout_height="36dp" 
       android:scaleType="centerInside" 
       app:srcCompat="@drawable/ic_deactive_nav" /> 

      <TextView android:id="@+id/tv_poll_two" 
       android:visibility="invisible" android:textStyle="bold" 
       android:text="2" android:gravity="center" 
       android:textColor="@color/white" 
       android:layout_width="36dp" android:layout_height="36dp" /> 

     </FrameLayout> 

     <FrameLayout android:layout_width="36dp" android:layout_height="36dp" 
      android:layout_alignParentRight="true"> 

      <ImageView 
       android:id="@+id/pager_img_three" 
       android:layout_width="36dp" android:layout_height="36dp" 
       android:scaleType="centerInside" 
       app:srcCompat="@drawable/ic_deactive_nav" /> 

      <TextView android:id="@+id/tv_poll_three" 
       android:visibility="invisible" android:textStyle="bold" 
       android:text="3" android:gravity="center" 
       android:textColor="@color/white" 
       android:layout_width="36dp" android:layout_height="36dp" /> 

     </FrameLayout> 


    </RelativeLayout> 

    <LinearLayout android:orientation="vertical" 
     android:layout_width="match_parent" android:layout_height="wrap_content"> 

     <LinearLayout android:id="@+id/pb_container" 
      android:layout_width="match_parent" android:layout_height="8dp" 
      android:background="@android:color/transparent" 
      android:gravity="bottom"> 

      <ProgressBar android:id="@+id/progress_bar" 
       style="@style/Widget.AppCompat.ProgressBar.Horizontal" 
       android:progressDrawable="@drawable/progress_bar_drawable" 
       android:indeterminate="false" 
       android:max="100" android:progress="0" 
       android:layout_width="match_parent" android:layout_height="8dp" /> 

     </LinearLayout> 

     <TextView android:text="Uploading Video Progress" 
      android:textColor="@color/app_body_text_3" android:gravity="center_horizontal" 
      android:layout_width="match_parent" android:layout_height="wrap_content" /> 

    </LinearLayout> 


</FrameLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/nv_poll_navigation" 
    android:background="@color/white" 
    android:layout_width="wrap_content" android:layout_height="match_parent" 
    android:fitsSystemWindows="false" android:layout_gravity="start" /> 

ответ

2

DrawerLayout должен иметь двух детей: основной вид содержимого и ящик для навигации. https://developer.android.com/training/implementing-navigation/nav-drawer.html#DrawerLayout

Таким образом, вы должны обернуть основное содержание с FrameLayout так:

<android.support.v4.widget.DrawerLayout 
     android:id="@+id/dl_poll_container" 
     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:background="@color/white" 
     android:layout_width="match_parent" android:layout_height="match_parent" 
     android:fitsSystemWindows="false"> 

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

     <LinearLayout android:id="@+id/ll_toolbar_container" 
         android:orientation="vertical" 
         android:layout_width="match_parent" android:layout_height="wrap_content"> 
      ... 
     </LinearLayout> 

     <FrameLayout android:background="@color/white" 
        android:layout_marginTop="?attr/actionBarSize" 
        android:layout_width="match_parent" android:layout_height="wrap_content"> 
      .... 
     </FrameLayout> 
    </FrameLayout> 

    <android.support.design.widget.NavigationView 
      android:id="@+id/nv_poll_navigation" 
      android:background="@color/white" 
      android:layout_width="wrap_content" android:layout_height="match_parent" 
      android:fitsSystemWindows="false" android:layout_gravity="start" /> 

</android.support.v4.widget.DrawerLayout> 
+0

Wow! Хороший улов!! Престижность !! :) Я бы не догадался об этом иначе! Большое спасибо ! Я собирался использовать совет @Arkde, когда увидел ваш ответ. – Mes

1

Существует метод в DrawerLayout имени setScrimColor со значением по умолчанию (какой-то из прозрачного темно-серого цвета). Вы можете использовать этот метод для изменения цвета, который нарисован поверх содержимого при открытии ящика. Вы можете установить его полностью прозрачным, если необходимо