Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FAB Color for backgroundTint not changing in Gingerbread version devices

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.

enter image description here

like image 326
Chandru Avatar asked Sep 12 '15 10:09

Chandru


2 Answers

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);
    }
like image 78
RBK Avatar answered Oct 10 '22 00:10

RBK


This is actually a bug in the library. There is an open bug report that you can see here.

like image 29
phxhawke Avatar answered Oct 10 '22 00:10

phxhawke