我想去掉按钮的阴影,使它看起来更平坦。
我现在有这个:
但我想要的是:
我想去掉按钮的阴影,使它看起来更平坦。
我现在有这个:
但我想要的是:
当前回答
材质设计按钮添加到按钮xml: 风格= " @style / Widget.MaterialComponents.Button.UnelevatedButton”
其他回答
科特林
stateListAnimator = null
Java
setStateListAnimator(null);
XML
android:stateListAnimator="@null"
它要求API级别为21
android:outlineProvider="none"
@Alt-Cat的答案对我有用!
r.t r. borderlessbuttonstyle不包含阴影。
按钮的文档很棒。
同样,你也可以在你的自定义按钮中,在第二个构造函数中设置这个样式。
public CustomButton(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.borderlessButtonStyle);
}
另一种选择是添加
style="?android:attr/borderlessButtonStyle"
到您的按钮xml,如这里所述 http://developer.android.com/guide/topics/ui/controls/button.html
一个例子是
<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" />
我使用自定义样式
<style name="MyButtonStyle" parent="@style/Widget.AppCompat.Button.Borderless"></style>
别忘了加上
<item name="android:textAllCaps">false</item>
否则按钮文本将是大写的。