Skip to content
A raised button that lowers down to 0dp of elevation
Java
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Update support library and fix gradle syntax highlighting Oct 29, 2016
gradle Add missing files - Fix #1 Feb 28, 2017
raiflatbutton Prepare for distribution Oct 29, 2016
screens Rename styles and add demo gif Oct 29, 2016
.gitignore Initial commit Oct 29, 2016
LICENSE.txt Add license Oct 29, 2016
README.md Update README.md Oct 30, 2016
build.gradle Prepare for distribution Oct 29, 2016
gradle.properties Prepare for distribution Oct 29, 2016
gradlew Initial commit Oct 29, 2016
gradlew.bat Initial commit Oct 29, 2016
settings.gradle Initial commit Oct 29, 2016

README.md

RaiflatButton

A raised button that lowers down to 0dp of elevation. From my blog post: https://rubensousa.github.io/2016/10/raiflatbutton

It behaves like a normal button on APIs < 21

Build

dependencies {
   compile 'com.github.rubensousa:raiflatbutton:0.1'
}

How to

Just add the following xml to your layout:

<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" />

If you want to resume the normal button behavior, just use:

button.setFlatEnabled(false);

Styling

Since RaiflatButton and RaiflatImageButton both extend AppCompatButton and AppCompatImageButton, you can reuse the same AppCompat styles.

Example:

<style name="RaiflatButtonPrimaryStyle" parent="Base.Widget.AppCompat.Button.Colored">
    <item name="android:colorControlNormal">?attr/colorPrimary</item>
</style>

License

Copyright 2016 Rúben Sousa

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.