Yupi
Yupi

Reputation: 4470

Toolbar shadow issue on Android lollipop 5.0

I was doing final touches on my app and noticed strange behavior on my toolbar on devices running 5.0 and above. On devices that are below 5.0 there is no strange line below my image which I setup as a backgroundDrawablefor toolbar but on devices 5.0 and above seems like toolbar is visible behind the image. I tried many approaches that I found mostly here on stackoverflow but nothing seems to work. I tried with transparent background but that didn't work. I created custom theme with also with transparent background but that didn't work too. Here are the images: Bellow Lollipop Lollipop and above

Code:

   <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:background="?attr/colorPrimary"
    android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolBar"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:background="@android:color/transparent"
        app:layout_scrollFlags="scroll|enterAlways">
        <ImageView
            android:id="@+id/icon"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_logo_final"
            android:layout_gravity="center"
            android:gravity="center"
            android:layout_marginRight="50dp"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="15dp"
            />
     </android.support.v7.widget.Toolbar>
 </android.support.design.widget.AppBarLayout>
  <android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:id="@+id/recyclerView">
   </android.support.v7.widget.RecyclerView>
  </android.support.design.widget.CoordinatorLayout>

Thanks in advance.

Upvotes: 0

Views: 78

Answers (2)

Adarsh
Adarsh

Reputation: 2269

It's due to the shadow feature of Toolbar.. so hide it..

Try..applying "app:elevation="0dp" in the "android.support.design.widget.AppBarLayout" to resolve this issue.

Upvotes: 1

rafsanahmad007
rafsanahmad007

Reputation: 23881

try this to remove shadow from toolbar:

 <style name="MyAppTheme" parent="android:Theme.Holo.Light">
    <item name="android:windowContentOverlay">@null</item>
</style>

Also set app:elevation="0dp" in AppBarLayout for hiding shadow in appbar

Upvotes: 1

Related Questions