Friday, 14 June 2019

Presenting a fragment over a fragment with transparent background

I'm using jetpack navigation to transition from a fragment to a detail fragment.

I need help presenting the detail fragment over the fragment that displays it.

See photo below to look what I am trying to achieve:

Eiffel Tower

On the 'Learn More' button, I am using navigate() to get to the detailed fragment:

Navigation.findNavController(view!!).navigate(R.id.toLandmarkDetailFragment,bundle)

I'm also using a basic fade_in / fade_out for Enter Exit on the Animations within the nav graph.

Here's the result I am getting:

result of presenting view not showing up in the detail view

Here's the XML for my detail fragment:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                             xmlns:app="http://schemas.android.com/apk/res-auto"
                                             xmlns:tools="http://schemas.android.com/tools"
                                             android:layout_width="match_parent"
                                             android:layout_height="match_parent"
                                             tools:context=".tab3.landmarkDetailFragment"
                                             android:id="@+id/frameLayout4" android:background="#B3000000">
    <android.support.constraint.ConstraintLayout
            android:layout_width="270dp"
            android:layout_height="277dp" app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintBottom_toBottomOf="parent" android:background="#FFFFFF" android:id="@+id/modal">

    </android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>

How can I set up the transition so that the detail fragment displays over the presenting view?

Bounty edit:

I am looking to display a fragment over a fragment, as seen in the Eiffel Tower image. In iOS this would be similar to presentation: Over Full Screen. I do not wish to use a DialogFragment, as I have far more control over animating the views in a normal Fragment.



from Presenting a fragment over a fragment with transparent background

No comments:

Post a Comment