I am facing an issue while changing backgroundTint color in xml for FAB, that the color has not assigned for devices with Gingerbread versions. I am really confused and don't know why it is behaving weird. I am completely stuck with this issue with a couple of hours triggering out the solution but I couldn't. Kindly help me with your tips and suggestions to resolve my issue. I am posting my code and screen shot of the issue for your reference. Thanks in advance.
include_fab.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
app:backgroundTint="#FF0000"
app:borderWidth="0dp"
app:elevation="5dp"
app:fabSize="normal"/>
Design support library in my gradle
compile 'com.android.support:design:23.0.0'
Screenshot of versions GingerBread and KitKat
Note: I am getting exact output of my requirement above GingerBread devices. Problem arises with GingerBread alone.
It may work
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FloatingActionButton v = (FloatingActionButton) findViewById(R.id.fab);
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xffff0000});
v.setSupportBackgroundTintList(csl);
}
This is actually a bug in the library. There is an open bug report that you can see here.
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