首页 > FloatingActionButton 设置背景色无效

FloatingActionButton 设置背景色无效

设置FloatingActionButton的代码如下:

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/enter_floating_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="40dip"
                android:layout_marginRight="10dip"
                android:clickable="true"
                app:background="#00FF00"
                app:backgroundTint="#00FF00"
                app:rippleColor="@android:color/red"
                app:fabSize="normal"
                android:src="@drawable/ic_done" />

但是设置了app:backgroundapp:backgroundTint之后FloatingActionButton的显示颜色还是原来的颜色而不是指定的颜色。另外app:rippleColor设置后按下的颜色也没有变,这个是为什么?我需要怎么改变它的背景色和按下的颜色?最好不要用主题里的accentColor


用Selector....

参考。。。
http://blog.csdn.net/lmj623565791/article/details/46678867


这个是github上的开源的FloatingActionButton感觉对于你说的设置背景颜色还是很方便的
https://github.com/makovkastar/FloatingActionButton


` floatingActionButton.setBackgroundTintMode(PorterDuff.Mode.SRC_OVER);

    floatingActionButton.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.float_ting)));`

你肯定没给FloatingActionButton设置点击事件。

【热门文章】
【热门文章】