I want to remove the shadow from the button to make it seem more flat.
I have this right now:
the @Alt-Cat answer work for me!
R.attr.borderlessButtonStyle doesn't contain shadow.
and the document of button is great.
Also, you can set this style on your custom button, in second constructor.
public CustomButton(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.borderlessButtonStyle);
}
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" />
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.
All above answers are great, but I will suggest an other option:
<style name="FlatButtonStyle" parent="Base.Widget.AppCompat.Button">
<item name="android:stateListAnimator">@null</item>
<!-- more style custom here -->
</style>