Reputation: 3090
So i'm using following a guide to implement fab transformation to a container. This was the code.
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.circularreveal.CircularRevealFrameLayout
android:id="@+id/sheet"
android:layout_gravity="bottom|center_horizontal"
android:visibility="invisible"
android:background="@color/secondaryColor"
app:layout_behavior="com.google.android.material.transformation.FabTransformationSheetBehavior">
</com.google.android.material.circularreveal.CircularRevealFrameLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_gravity="bottom|end"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
It works fine but
FabTransformationSheetBehavior
is deprecated now. I googled and came up with this
com.google.android.material.transition.MaterialContainerTransform
which should now be used instead of that. But when I replace it , I get a layout inflation error.
Could not inflate Behavior subclass com.google.android.material.transition.MaterialContainerTransform
Upvotes: 1
Views: 623
Reputation: 106
Looks like the MaterialContainerTransform cannot be used in layout_behavior attribute.
You need to create an instance of MaterialContainerTransform and initialize it with some parameters.
Here is an example which kind of worked for my case:
MaterialContainerTransform transform = new MaterialContainerTransform();
transform.setStartView(your FAB goes here);
transform.setEndView(view which you are transitioning to);
transform.setPathMotion(new MaterialArcMotion()); //optional
transform.setScrimColor(Color.TRANSPARENT); //optional
TransitionManager.beginDelayedTransition(container, transform);
Additionally, with this approach you don't actually need to stick to this kind of layout and specific hierarchy anymore.
Here is the link you can refer to learn more: https://material.io/develop/android/theming/motion
Upvotes: 1