Android Bits
Published in

Android Bits

Android: Material buttons

Credit: material.io

Adding resources

dependencies {
//replace X.X.X with the latest version
compile 'com.android.support:appcompat-v7:X.X.X'
}
public class ButtonActivity extends AppCompatActivity {
...
}
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/action_click_me" />

Styling

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="colorButtonNormal">@color/colorPrimary</item>
<item name="colorControlHighlight">@color/colorAccent</item>
</style>
<style name="PrimaryButton" parent="Theme.AppCompat">
<item name="colorButtonNormal">@color/colorPrimary</item>
<item name="colorControlHighlight">@color/colorAccent</item>
</style>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/action_click_me"
android:theme="@style/PrimaryButton" />

Flat button

<style name="PrimaryFlatButton" parent="Theme.AppCompat.Light">
<item name="android:buttonStyle">@style/Widget.AppCompat.Button.Borderless.Colored</item>
<item name="colorControlHighlight">@color/colorAccent</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button_normal"
android:theme="@style/PrimaryFlatButton" />

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store