RaiflatButton Android Library

repository·master·Indexed 43 days ago

https://github.com/rubensousa/raiflatbutton

An Android library providing RaiflatButton and RaiflatImageButton components that feature a raised appearance which lowers to 0dp elevation when pressed. Designed to work with AppCompat styles, it allows for standard theme attribute reuse and provides a setFlatEnabled(false) method to disable the custom elevation behavior.

Tokens
593
Snippets
4
Records
4
Agent score
6%

What's inside RaiflatButton

  1. Style RaiflatButton using AppCompat styles

    master

    Because RaiflatButton and RaiflatImageButton extend AppCompatButton and AppCompatImageButton respectively, you can apply standard AppCompat styles to them. This allows you to reuse existing theme attributes like colorControlNormal.

    <style name="RaiflatButtonPrimaryStyle" parent="Base.Widget.AppCompat.Button.Colored">
        <item name="android:colorControlNormal">?attr/colorPrimary</item>
    </style>
  2. Use RaiflatButton and RaiflatImageButton in layouts

    master

    You can include RaiflatButton or RaiflatImageButton directly in your XML layout files. RaiflatButton is used for text buttons, and RaiflatImageButton is used for icon-based buttons.

    <com.github.rubensousa.raiflatbutton.RaiflatButton
        android:id="@+id/normalButton"
        style="@style/Base.Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Colored" />
        
    <com.github.rubensousa.raiflatbutton.RaiflatImageButton
        android:id="@+id/imageButton"
        style="@style/Base.Widget.AppCompat.Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_android" />