Reputation: 179
I need to create buttons and headers using colors and styles similar to play store UI. How can i create a button using colors alone without using drawables? When i fill red or green color to the button not getting such effect like in play store app
Upvotes: 0
Views: 1726
Reputation: 442
android:drawableLeft="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
android:drawableStart="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
you can add this in your button
<Button ...
....
/>
whatever drawable u want to use ,you can put there
Upvotes: 0
Reputation: 1487
Here's a quick example for the buttons showing what you can do using xml only:
<Button
android:background="@drawable/button_red_round_corners"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
android:drawableStart="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
android:paddingLeft="8dp"
android:drawablePadding="8dp"
android:textAllCaps="true"
android:gravity="left|center_vertical"
android:textColor="@android:color/white"
android:text="Clipboard" />
where button_red_round_corners
is defined in your drawable
folder as
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#EE0000" />
<corners android:radius="4dp" />
Result:
The only problem is that there's no touch feedback if you use the android:background
attribute :-(
There should be a way using Drawable Selectors though.
Upvotes: 3