How to remove the border around the toolbar?
Asked Answered
D

4

7

In my app I am using a toolbar and it seems there are borders around it that I'd like to get rid of : enter image description here

and I created it like that :

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

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center"
        android:minHeight="?attr/actionBarSize"/>

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

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

and I use it like that :

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

    <include
        layout="@layout/app_bar_main_light"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

And I never found an attribute or styling specifying what is this border.

Descendible answered 17/11, 2016 at 0:2 Comment(0)
C
8

I tried it by without AppBarLayout, and it's working. Don't use AppBarLayout, just use Toolbar as it is.

Cultivation answered 7/12, 2016 at 10:19 Comment(3)
Yes, works for me as well. Do you know what in the AppBarLayout makes this "shadow" ?Descendible
@Descendible Sorry, Idk. But this same layout you can see in playstore app's search bar, you can try to make it beautiful like that also.Cultivation
yes it works but only for post-lollipop devices. should include appbarlayout for pre-lollipop devices.Duane
B
1

If @joyl answer works but still you do not wish to remove your AppBarLayout then set elevation to 0 in AppBarLayout like follows:

<com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp">
Bifarious answered 26/10, 2019 at 11:37 Comment(0)
O
1

This is my solution.

android:stateListAnimator="@null"
Oral answered 26/3, 2022 at 8:3 Comment(0)
M
0

just give transparent background to appbar like this

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/app_bar"
    android:background="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.google.android.material.appbar.MaterialToolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</com.google.android.material.appbar.AppBarLayout>
Midshipman answered 30/7 at 10:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.