Kotlin set RecyclerView Item's particular animations between fragments

43 Views Asked by At

I am using Navigation Library to navigate and animate. My code is like that when i do transitions;

private val onClicked = object :MyAdapter.OnItemClickListener{
    override fun onClicked(id: Int) {
        val fragment = FragmentB()
        val bundle = Bundle()
        bundle.putInt("id",id)
        fragment.arguments = bundle
        findNavController().navigate(R.id.action_fragmenta_to_fragmentb, bundle)
}

<fragment
    android:id="@+id/fragmenta"
    android:name="com.ahmetkaan.example.rw"
    android:label="fragment_a"
    tools:layout="@layout/fragmenta" >
    <action
        android:id="@+id/action_fragmenta_to_fragmentb"
        app:destination="@id/fragmentb"
        app:enterAnim="@anim/fade_in"
        app:exitAnim="@anim/fade_out"/>
</fragment>

I wanted to do a transition like, Fragment B will grow starting from within the selected Recyler View item and in milliseconds it will fill the screen so it will be my transition. Seems easy but i am using grid layout so every item has different positions on screen and i dont want to start the animation from a spesific place, i want to start animation from item's middle. So its changing according to item and its place. I did some research and understand that i cant use this Navigation's animation component. I encountered with transition files and shared elements transition but somehow I couldn't run the codes I wrote. I dont know that are they were right ways but I guess I couldn't code it in a structured way. Here is a little visual example of the animation that i want;

enter image description hereenter image description hereenter image description hereenter image description here

As you can see i touched an element which is at left and top side and animation starts from the exact position of the item. It's size increased and so that the transition occured. How can i make that in a structural way? Thanks in advance.

0

There are 0 best solutions below