Wednesday 21 October 2020

no animation when pressing back button on header in android fragment

I have a back button on my fragment when I press on it I don't see any animation (like in the activity that circle that I see for a split second when I press the back button)

I'm adding a back button to the fragment in the code like this:

    mToolbar.setTitle(R.string.tyto_setup_title);

    mToolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp));

    mToolbar.setNavigationOnClickListener(v -> {
        if (getActivity() != null) {
            getActivity().getSupportFragmentManager().beginTransaction().remove(MyFragment.this).commit();
        }
    });

here is my XML for the header inside the fragment

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/AppBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/MYTheme.AppBarOverlay"
        app:titleTextAppearance="@style/MyToolbarTitle"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/myToolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            app:titleTextAppearance="@style/MyToolbarTitle"
            app:popupTheme="@style/MyTheme.PopupOverlay">

            <TextView
                android:id="@+id/mySkipButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_gravity="end"
                android:layout_marginStart="20dp"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="16dp"
                android:layout_marginBottom="10dp"
                android:text="@string/tyto_live_stream_action_bar_label"
                android:textColor="@color/my_color_white"
                android:textSize="14sp" />

        </androidx.appcompat.widget.Toolbar>

    </com.google.android.material.appbar.AppBarLayout>

do you know how to show the animation (that split second animation) when i press the back button ?



from no animation when pressing back button on header in android fragment

No comments:

Post a Comment