Reputation: 1128
I'm trying to add a focus effect more noticeable to the FloatingActionButton of the android.support.design.
So far, I've tested to add a custom background to the button:
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_done_24dp"
android:background="@drawable/focus_gold"
app:backgroundTint="#F7A200"
app:pressedTranslationZ="12dp" />
With the drawable focus_gold being:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="#ff9800"/>
</selector>
Here is the result (the red background is normal):
Does anyone have an idea to set a nice and simple focus effect on a fab button with this library?
Thanks,
Vincent
Upvotes: 2
Views: 5737
Reputation: 2611
My suggestion,
app:backgroundTint="@color/focus_gold"
Make sure to change focus_gold.xml to this
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#ff9800" android:state_focused="true"/>
<item android:color="#F7A200" />
</selector>
Upvotes: 15
Reputation: 994
you can try the unofficial FloatingActionButton library! Here is the github link: https://github.com/makovkastar/FloatingActionButton
Hope it helped!
Upvotes: 2