FAB Color for backgroundTint not changing in Gingerbread version devices
L

2

15

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

Lamoree answered 12/9, 2015 at 10:8 Comment(10)
I'm having similar problems, it also causes crashes. Are you using Genymotion?Ambience
Using both but i didnt try this in genymotion.Lamoree
I dont have genymotion gingerbread versions, but it is working fine with latest versions in genymotionLamoree
I only noticed this on gingerbread Genymotion, wondering if this might be a Genymotion issue.Ambience
no yar in device also this issue is replicating.Lamoree
It seems like this issue was not present in support design v22Ambience
yes of course. you are right. It is really a critical one that should be sorted out because still GingerBread users are in practice. Around 20 percent of the people overall uses GingerBread.Lamoree
See this post: https://mcmap.net/q/95178/-floatingactionbutton-example-with-support-libraryContraband
I have this same issue on hardware (T-Mobile HTC myTouch 4g running 2.3) and on a normal 2.3 emulator, so don't blame genymotion. I think it may be a generic gingerbread problem.Vue
@Vue yes u r right. It is not genymotion issue. I recently tested with Samsung-S2 and same problem arises.Lamoree
T
2

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);
    }
Tunny answered 21/9, 2015 at 19:44 Comment(2)
Thanks. will check and let you knowLamoree
@Lamoree do it work for you, if yes, please accept answer so that other people get correct answer, ask if any query do you have. :)Tunny
E
1

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

Engelbert answered 22/9, 2015 at 18:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.