I have a ConstraintLayout wrapping my FABs section in the bottom right of the app. I use a layout and not only the buttons because I have more views all around the FABs (they are omitted in the example below, the real layout is more complex). The layout has a CoordinatorLayout as main parent. I have two FABs, one near to the other, when I click the first one the second animates and move up using ViewPropertyAnimations, then I click the second one and other views should appear. ISSUE IS: the translated FAB isn't clickable. I can click on it before the animation starts but not after translation.
What I've found so far:
Can you help me to fix this?
Dependencies versions
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
Fragment layout (it's a simplified version, the real one has many views)
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:clipChildren="false" >
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="24dp"
android:layout_marginBottom="24dp"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_dodgeInsetEdges="bottom" >
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:src="@android:drawable/ic_delete"
android:elevation="3dp"
android:layout_gravity="end|bottom"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="@+id/fab1"
app:layout_constraintEnd_toStartOf="@+id/fab1"
app:layout_constraintTop_toTopOf="@+id/fab1" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:elevation="6dp"
android:layout_gravity="end|bottom"
android:src="@android:drawable/btn_star_big_on"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:fabSize="normal"
android:focusable="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Animation code
FloatingActionButton fab1 = requireView().findViewById(R.id.fab1);
FloatingActionButton fab2 = requireView().findViewById(R.id.fab2);
fab1.setOnClickListener(v -> fab2.animate().translationY(-200));
fab1.setOnLongClickListener(v -> {
fab2.animate().translationY(0);
return true;
});
fab2.setOnClickListener(v -> Toast.makeText(requireContext(),"click",Toast.LENGTH_SHORT).show());
The issue seems solved with constraintlayout:2.1.0