Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove button shadow (android)

People also ask

How to remove shadow of button in android studio?

Kotlin Android – Remove Shadow of Floating Action Button Hence, we used app:elevation in the XML. To remove the shadow of Floating Action Button dynamically or programmatically in Kotlin activity file, set compatElevation parameter of the FAB with 0.0F.

What is elevation in Android?

Elevation helps users understand the relative importance of each element and focus their attention to the task at hand. The elevation of a view, represented by the Z property, determines the visual appearance of its shadow: views with higher Z values cast larger, softer shadows.


Another alternative is to add

style="?android:attr/borderlessButtonStyle"

to your Button xml as documented here http://developer.android.com/guide/topics/ui/controls/button.html

An example would be

<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage"
style="?android:attr/borderlessButtonStyle" />

A simpler way to do is adding this tag to your button:

android:stateListAnimator="@null"

though it requires API level 21 or more..


Kotlin

stateListAnimator = null

Java

setStateListAnimator(null);

XML

android:stateListAnimator="@null"

I use a custom style

<style name="MyButtonStyle" parent="@style/Widget.AppCompat.Button.Borderless"></style>

Don't forget to add

<item name="android:textAllCaps">false</item>

otherwise the button text will be in UpperCase.


Material desing buttons add to button xml: style="@style/Widget.MaterialComponents.Button.UnelevatedButton"


try : android:stateListAnimator="@null"