Remove shadow between Toolbar and the rest of the layout

Asked

Viewed 1,195 times

1

I’m working on a project where I need to put one CalendarView next to a Toolbar. The problem is that the Toolbar gets a shadow on the bottom, where I’d like you to join the CalendarView. I tried to look into it, but I don’t know what the ideal search terms would be and I ended up finding nothing.

Sombra

Currently, that’s how the layout is. That’s my main XML:

<?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"
    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 that contains 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 even researched a little about elevation (Elevation) and clipping, but I didn’t get any results.

Someone can give me a light?

2 answers

5


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

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

Being from the design library, the AppBarLayout defines an attribute elevation and has an implementation for devices prior to 5.0.

  • Thank you very much, solved my problem!

  • Wakim, ask me one more question: is it possible to remove (or change color) the line and commands where "October 2015" is written? I managed to change everything but these two items.

  • @Renanlazarotto, to stylize the CalendarView take a look at the parameters of style which it accepts: http://developer.android.com/reference/android/widget/CalendarView.html. If no help, it has to go to an external lib, which is closer than you want it to be..

  • Thanks again, @Wakim. I’ll have to find another one anyway :/

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.
  • 2

    Posts in English are not accepted here. I recommend translating or removing. While you’re at it, visit these links whenever you have a little time: [Tour], [Answer] and [Help].

Browser other questions tagged

You are not signed in. Login or sign up in order to post.