Android: Floating Action Button Appears With Transparent Background
I've added FloatingActionButton to my application with a png icon ic_send. When I was testing using gingerbread device it keeps showing the button with no background color, but on
Solution 1:
you must set
app:backgroundTint="@color/yourcolor"
Solution 2:
Solution 3:
I had a similar issue with FloatingActionButton(FAB). In my case I was using fragments in Activity and I had FAB in my activity's layout file. So fragment renders on top of FAB. So I had to add fab.bringToFront();
in onPostResume()
method in my activity to get it work.
@OverrideprotectedvoidonPostResume() {
super.onPostResume();
fab.bringToFront(); // fab - reference of FloatingActionButton
}
Also, Check elevation of the layout should be smaller than FAB's elevation.
Solution 4:
remove app:elevation="2dp" on FloatingActionButton
<android.support.design.widget.FloatingActionButtonandroid:id="@+id/btn_next"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_margin="@dimen/dp15"android:src="@drawable/ic_send"
//app:elevation="2dp"app:fabSize="normal"app:layout_anchor="@id/card"app:layout_anchorGravity="bottom|right|end" />
Instead, Use given snippet
<android.support.design.widget.FloatingActionButtonandroid:id="@+id/btn_next"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_margin="@dimen/dp15"android:src="@drawable/ic_send"app:fabSize="normal"app:layout_anchor="@id/card"app:layout_anchorGravity="bottom|right|end" />
Post a Comment for "Android: Floating Action Button Appears With Transparent Background"