Search code examples
androidandroid-viewfloating-action-buttonelevation

FAB: pressedTranslationZ does not work


My floating action button does not elevate when pressed.

The layout file :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/white"
android:id="@+id/layout">

<android.support.v7.widget.RecyclerView
    android:id="@+id/multiple_tally_recyclerview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.FloatingActionButton
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="16dp"
    android:layout_marginRight="16dp"
    app:backgroundTint="@android:color/holo_orange_dark"
    app:elevation="6dp"
    app:pressedTranslationZ="12dp"
    app:srcCompat="@drawable/ic_add_black_24dp" />
    </RelativeLayout>

It seems that app:pressedTranslationZ is not working properly. How can I fix that?


Solution

  • Solved. I was just testing my FAB without setting an OnClickListener, finally I set the OnClickListener then it started to elevate on click.