我想去掉按钮的阴影,使它看起来更平坦。

我现在有这个:

但我想要的是:


当前回答

材质设计按钮添加到按钮xml: 风格= " @style / Widget.MaterialComponents.Button.UnelevatedButton”

其他回答

带有自定义按钮;使用R.style。Widget_AppCompat_Button_Borderless, Kotlin way-

class CSButton @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = R.style.Widget_AppCompat_Button_Borderless
) : AppCompatButton(context, attrs, defStyleAttr)

科特林

stateListAnimator = null

Java

setStateListAnimator(null);

XML

android:stateListAnimator="@null"

简单的

 android:elevation="0dp"

try: android:stateListAnimator="@null"

它要求API级别为21

        android:outlineProvider="none"