The toolbar background turns white when set to transparent

There are many questions about creating a transparent toolbar. but none of these answers solved my problem.

My problem here is that I want to make a transparent toolbar, and it should have the main color background only when the user scrolls up or down. But initially it should be transparent until it scrolls up / down.

for this I have the following topic:

<resources>   
     <!-- Base application theme. -->
        <style name="AppTheme" parent="AppTheme.Base"/>
        <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
          <item name="android:windowActionBarOverlay">true</item>
          <item name="colorPrimary">@color/colorPrimary</item>
          <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
          <item name="colorAccent">@color/colorAccent</item>
          <item name="android:windowNoTitle">true</item>
           <item name="windowActionBar">false</item>
        </style>

activity_main.xml:

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

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        .....

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

app_bar_main:

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

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@android:color/transparent"/>

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

        <include layout="@layout/content_main" />


    <android.support.design.widget.FloatingActionButton
      ....
      ....
    </android.support.design.widget.CoordinatorLayout>

But instead of getting a transparent toolbar, I got a toolbar with a white background.

can you check what is wrong with my .xml theme?

I use the design support library 23.1.1 Thank you

+4

Source: https://habr.com/ru/post/1621482/


All Articles