How to Disable or Customize Shadow Effect in Material Design Components for Android Studio

35 views Asked by At

I'm developing an Android app using Android Studio, and I'm using Material Design components, specifically BottomNavigationView. I want to disable or customize the shadow effect on this BottomNavigationView. I've tried setting android:elevation="0dp" directly in the layout XML file, but the shadow effect still persists. How can I properly disable or adjust the shadow effect on Material Design components like BottomNavigationView?picture of the effect that I dont want

Here's the layout XML code I've tried:

<com.google.android.material.bottomnavigation.BottomNavigationView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/footer_menu"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:itemIconTint="@color/selector_footer"
    app:labelVisibilityMode="unlabeled"
    android:background="@color/white"
    app:menu="@menu/footer_menu"
    app:itemIconSize="32dp"/>

And this is the content of selector_footer.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/color_button"
        android:state_checked="true"/>

    <item android:color="@color/color_button_before_pressed"
        android:state_checked="false"/>
</selector>
1

There are 1 answers

0
Laser On

So I had the same problem as u can see here. And I found an easy fix for this.

You Only need to change the theme of your project and then it will be gone. Check this in your current project under res\values\themes and set the below theme.

<resources>
    <!-- MyApplication is your application. you only need to change the parent theme -->
    <style name="Base.Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">

Then it will be solved. Just change the parent part.

I hope this helps.