0

Mon bouton d'action flottant ne se soulève pas lorsqu'il est enfoncé.FAB: pressedTranslationZ ne fonctionne pas

Le fichier de mise en page:

<?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> 

Il semble que app:pressedTranslationZ ne fonctionne pas correctement. Comment puis-je résoudre ce problème?

Répondre

0

Résolu. Je testais juste mon FAB sans régler un OnClickListener, enfin j'ai mis le OnClickListener puis il a commencé à élever sur clic.

-1

Vous auriez pu manquer la mise OnClickListener

sur FAB pressedTranslationZ provoque l'ombre de croître quand pressed.Simply setOnClickListener comme ci-dessous:

fab.setOnClickListener(new View.OnClickListener() { 
      @Override 
public void onClick(View view) { 
      // implementation Code here 
    }