Remove shadow between toolbar and rest of the layout

1

I'm working on a project where I need to put a CalendarView next to a Toolbar . The problem is that Toolbar gets a shadow on the bottom, where I'd like it to merge to CalendarView . I tried to search about, but I do not know what the ideal search terms would be and I did not find anything at all.

Currently,thisishowthelayoutis.ThisismymainXML:

<?xmlversion="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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".PontoDiaActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="0dp"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            android:padding="0dp"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

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

    <fragment 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:id="@+id/fragment"
        android:name="com.renanlazarotto.ponto.fragments.PontoDiaActivityFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:layout="@layout/fragment_ponto_dia" />


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

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

And this is the fragment containing the CalendarView:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".PontoDiaActivityFragment">

    <CalendarView
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/red_500" />

    <TextView
        android:id="@+id/selected_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text" />
</LinearLayout>

Note that it is still a simple project without many elements. I did a little research on elevation and clipping, but I did not get any results.

Can someone give me a light?

    
asked by anonymous 09.10.2015 / 03:56

2 answers

5

The shadow you see is AppBarLayout , to get it just set it:

<android.support.design.widget.AppBarLayout
    ...
    app:elevation="0dp">

Because it is from the design library, AppBarLayout defines a elevation attribute and has an implementation for devices prior to 5.0.

    
09.10.2015 / 13:15
0

In my case, I only include this parameter in my context class:

getSupportActionBar().setElevation(0);

You can change some of the attributes of the Java class using:

getSupportActionBar().setTitle("Title")
getSupportActionBar().setHomeButtonEnabled(true);
... e outros componentes.
    
02.09.2016 / 17:56