I want to do material style flat buttons for systems before Lollipop. I'm using Android 4.4.4 and my Play Store looks like the following:
The buttons and icons are neatly arranged as in the APPS, GAMES, BOOKS.
The MORE button shows buttons a button without an icon.
So how do I do cute buttons like this, which glow when clicked, have the icon neatly arranged there, and have the little rounded corners. Using drawableLeft doesn't work because the icons get too big.
I'm guessing that there's a way to put this into a style sheet, because Google seems to do it quite consistently across their other apps.
Button without icon
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sign_up"
android:background="@drawable/action_button"
android:textColor="@color/primary_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginRight="5dp"
android:id="@+id/fl_btn_signup" />
In Drawable you can use this action_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape android:dither="true" android:shape="rectangle">
<corners android:bottomLeftRadius="3dp" android:bottomRightRadius="3dp" android:topLeftRadius="3dp" android:topRightRadius="3dp" />
<solid android:color="#689F38" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:dither="true" android:shape="rectangle">
<corners android:bottomLeftRadius="3dp" android:bottomRightRadius="3dp" android:topLeftRadius="3dp" android:topRightRadius="3dp" />
<solid android:color="#80689F38" />
</shape>
</item>
</selector>
If you want to use icons with this buttons then use android:drawableLeft
in your Button xml or you can take a LinearLayout
with Horizontal orientation & with ImageView
& TextView
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center_vertical"
android:background="@drawable/action_button"> //Same xml
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_apps_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="APPS"
android:gravity="center"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With