Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:elevation applied to toolbar AND its title

Tags:

android

I use a very simple style to format my Toolbar, I use android:elevation to display a shadow under the Toolbar like this:

<style
    name="AppToolbarTheme"
    parent="AppTheme">

    <item name="android:background">@color/colorPrimary</item>
    <item name="android:titleTextColor">@android:color/white</item>
    <item name="android:elevation">4dip</item>
</style>

And I'm applying it simply like that:

<Toolbar
    android:id="@+id/main_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppToolbarTheme"/>

The shadow displays under the toolbar like I want, howerver it is also somehow applied to the title of the toolbar which looks very weird:

enter image description here

like image 285
Gaetan L. Avatar asked Oct 17 '22 11:10

Gaetan L.


1 Answers

Remove <item name="android:elevation">4dip</item> from style and put it in toolbar xml

<Toolbar
    android:id="@+id/main_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppToolbarTheme"
    android:elevation="4dp"/>
like image 96
Aniruddh Parihar Avatar answered Oct 21 '22 07:10

Aniruddh Parihar