1

I have implemented floating action with list item and setting elevation from layout and run time on bind data as well. Then following issues occur:

  1. fab elevation showing on first item only that is from xml resource I think.
  2. setElevation() not working run time.
  3. fab show()/hide() also not working with scale animation.

xml code is here:

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_btn_video"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/parentLayout"
            android:layout_marginEnd="@dimen/fab_margin"
            android:layout_marginRight="@dimen/fab_margin"
            android:src="@drawable/ic_av_videocam"
            app:elevation="@dimen/fab_shadow"
            tools:targetApi="lollipop" />
Cœur
  • 37,241
  • 25
  • 195
  • 267
JosephM
  • 2,935
  • 4
  • 18
  • 28
  • http://stackoverflow.com/questions/26963219/how-to-create-a-floating-action-button-fab-in-android-using-appcompat-v21 – Techidiot Sep 19 '16 at 11:20
  • @Techidiot i'm using official library fab. the issue is shadow not showing run time. – JosephM Sep 19 '16 at 11:26

1 Answers1

1

This worked for me to change elevation:

fab.setCompatElevation(8f); //API>=21

You can try to use com.google.android.material.floatingactionbutton.FloatingActionButton instead of android.support.design.widget.FloatingActionButton. This will allow you to use show() and hide() methods.