Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the elevation of AppBarLayout to 0

My layout file is like :

<?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:elevation="0dp"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="256dp"
    android:fitsSystemWindows="true"
    android:elevation="0dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:elevation="0dp"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginEnd="50dp"
        app:expandedTitleMarginStart="50dp"
        app:titleEnabled="false"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar
            android:id="@+id/main_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:elevation="0dp"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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

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


<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerview_worthiness_detail"
    ...
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

<com.yidoutang.app.widget.DetailAvatarView
    android:id="@+id/iv_header_worthiness_detail"
    android:layout_width="@dimen/header_size_datail"
    android:layout_height="@dimen/header_size_datail"
    android:clickable="true"
    android:elevation="0dp"
    app:backgroundTint="@color/fab_color_primary"
    app:border_color="@color/white"
    app:border_width="1dp"
    app:layout_anchor="@id/appbar"
    app:layout_anchorGravity="bottom|center_horizontal"
    app:layout_behavior="com.yidoutang.app.widget.behavior.AvatarBehavior"
    app:rippleColor="@android:color/darker_gray" />

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

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

I set the android:elevation="0dp" to Toorbar , CoordinatorLayout and AppBarLayout, but when it closes, it still have the elevation.

Something like the image

enter image description here

how can I remove the elavation?

like image 246
naiyu Avatar asked Dec 30 '15 10:12

naiyu


People also ask

How do I remove shadow from AppBarLayout?

Simply use app:elevation="0dp" inside "AppBarLayout" to remove the shadow. It has always worked for me. Hope it works for you.

What is the use of AppBarLayout in Android?

AppBarLayout is a vertical LinearLayout which implements many of the features of material designs app bar concept, namely scrolling gestures. Children should provide their desired scrolling behavior through AppBarLayout.

How do I get rid of the shadow bar on my Android?

ANSWER: Simply use app:elevation="0dp" inside “AppBarLayout” to remove the shadow.

What is appbarlayout in Android?

AppBarLayout is a vertical LinearLayout which implements many of the features of material designs app bar concept, namely scrolling gestures. Children should provide their desired scrolling behavior through AppBarLayout.LayoutParams.setScrollFlags (int) and the associated layout xml attribute: app:layout_scrollFlags .

How to detect if an appbarlayout should be lifted?

public AppBarLayout (Context context, AttributeSet attrs, int defStyleAttr) Add a listener that will be called when the offset of this AppBarLayout changes. BaseOnOffsetChangedListener: The listener that will be called when the offset changes.] Returns the id of the view that the AppBarLayout should use to determine whether it should be lifted.

How to bind a scrolling view to an appbarlayout?

AppBarLayout also requires a separate scrolling sibling in order to know when to scroll. The binding is done through the AppBarLayout.ScrollingViewBehavior behavior class, meaning that you should set your scrolling view's behavior to be an instance of AppBarLayout.ScrollingViewBehavior.

Why can't I use appbarlayout within a viewgroup?

If you use AppBarLayout within a different ViewGroup, most of its functionality will not work. AppBarLayout also requires a separate scrolling sibling in order to know when to scroll.


2 Answers

Use app:elevation="0dp" to remove the elevation

like image 186
Punit Sharma Avatar answered Oct 11 '22 11:10

Punit Sharma


Instead of

android:elevation="0dp"

try

app:elevation="0dp"
like image 41
Bartek Lipinski Avatar answered Oct 11 '22 10:10

Bartek Lipinski