2

toolbar buttons

I want to remove the shadow from these imagebuttons in my toolbar, but I can't seem to do it. I've tried setting the elevation, borderless style, and setting stateListAnimator as null. (These were suggestions on other posts.)

EDIT: Find the updated XML below. I have tried about every single suggestion in order to remove the shadows. (Even combined almost all of them) But I still can't get rid of them.

Main Layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">
    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context="com.tqamobile.partyme.MainActivity">
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay">
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:background="#00aaaaaa"
                    android:layout_gravity="right"
                    android:layout_height="match_parent">
                    <ImageButton
                        android:id="@+id/notification_button"
                        android:layout_height="match_parent"
                        android:layout_width="wrap_content"
                        android:elevation="0dp"
                        android:background="@android:color/transparent"
                        android:stateListAnimator="@null"
                        android:theme="@style/AppTheme.ToolbarButton"
                        android:src="@drawable/ic_no_notifications_action" />
                </LinearLayout>
            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.AppBarLayout>
        <include
            layout="@layout/content_main" />
    </android.support.design.widget.CoordinatorLayout>
    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="start"
        app:itemTextColor="@color/colorAccent"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/menu_navigation" />
</android.support.v4.widget.DrawerLayout>

Styles

<style name="AppTheme.ToolbarButton" parent="@style/Widget.AppCompat.Button.Borderless"/>
Tristan
  • 1,608
  • 1
  • 20
  • 34

2 Answers2

0

Change background of buttons from your current attributes to @null like this:

android:background="@null"
Xenolion
  • 12,035
  • 7
  • 33
  • 48
0

You should add your buttons as menu items instead.

Full guide here: https://stackoverflow.com/a/31477092/4974603

    <?xml version="1.0" encoding="utf-8"?>
   <menu
        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"
        tools:context=".MainActivity">
        <item
            android:id="@+id/action_settings"
            android:orderInCategory="100"
            android:title="@string/action_settings"
            app:showAsAction="never" />
        <item
            android:id="@+id/action_search"
            android:orderInCategory="200"
            android:title="Search"
            android:icon="@drawable/ic_search"
            app:showAsAction="ifRoom"
            ></item>
        <item
            android:id="@+id/action_user"
            android:orderInCategory="300"
            android:title="User"
            android:icon="@drawable/ic_user"
            app:showAsAction="ifRoom"></item>

    </menu>
Android
  • 814
  • 1
  • 9
  • 21
  • I implemented this, but it just adds more list items inside the drawer. I want buttons at the top on the header. – Tristan Oct 05 '17 at 01:06