question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MaterialButton] android:elevation alway use default value

See original GitHub issue

Expected behavior: android:elevation works for MaterialButton even not applying a style.

Source code: NOT WORK

<com.google.android.material.button.MaterialButton
        android:layout_height="64dp"
        android:layout_width="64dp"
        android:elevation="20dp"" />

WORK

<com.google.android.material.button.MaterialButton
        style="@style/Widget.MaterialComponents.Button.TextButton"
        android:layout_height="64dp"
        android:layout_width="64dp"
        android:elevation="20dp"" />

Android API version: Android 9

Material Library version: 1.2.0-alpha06

Device: XiaoMi A1

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

20reactions
dsn5ftcommented, Apr 23, 2020

@jaychang0917 it looks like you have to null out the button’s default state list animator:

android:stateListAnimator="@null"

See this similar stack overflow post:

https://stackoverflow.com/questions/38278179/android-elevation-not-showing-shadow-on-button/38278308

8reactions
mecoFaridcommented, Dec 4, 2021

android:stateListAnimator=“@null

I am 100% sure this will fuck up some other functionality

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android elevation not showing shadow on Button
The default Button style under Material has a StateListAnimator that controls the android:elevation and android:translationZ properties.
Read more >
My journey using Android Material Design Button - Medium
From my observation, the Android Material Button (the one with Elevation and Shadow) are seldom use. The buttons are normally flat, makes me...
Read more >
Elevation - Material Design
All elements have default values for resting elevation and dynamic elevation offsets. Certain components are positioned at higher elevations than others, ...
Read more >
MaterialButton - Android Developers
A convenience class for creating a new Material button. This class supplies updated Material styles for the button in the constructor.
Read more >
material_button.dart - Google Git
To create a custom Material button consider using [TextButton], ... Defaults to 2, the appropriate elevation for raised buttons. The value. /// is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found