Shared Element Transition between Recyclerview and Detailsfragment: elevation, hierarchy, bringToFront - android

I have some experience working with shared element transitions and fragment transition but I got stuck at the following problem.
I have a RecyclerView with items, if you click on one of the items it uses a ChangeBounds transition to go to the details page. This works fine. When I press the back button, the transition takes place again using the ChangeBounds transition. The only problem is when returning, the transition animates the item underneath the other items in the RecyclerView.
So what I'm trying to accomplish is the elevate the item above the other items when the return animation takes place. I tried elevating the shared element by using
setElevation(1000);
But this doesn't seem to have any effect.
I tried everything I could find on the internet but there ain't much examples of this specific problem.
Any feedback is welcome :)
Cheers!

Maybe it's to late, but for me it was relevant.
Tried many things to make it work not underneath other objects.
The solution was to put clipChildren='false' to destination fragment layout for the whole hierarchy to shared element.
In this case shared element could be drawn out of viewpager of other viewgroup that is not expanded to match parent.

Related

How to include an unattached View in the activity transition?

I draw a View that is not attached to any parent.
It's a decoration for a RecyclerView. The view sticks to the bottom and disappears when its counter part comes up in the list.
All this works fine but:
When i leave the activity the View doesn't fade with the rest of the
views in the activity's transition.
It stays until the end of the animation and then disappears
immediately.
( see large green view in the demo )
How do i include this unattached View in the activity's exit transition?
I've create a minimal Android Studio Project to replicate the issue:
https://github.com/Ostkontentitan/transition-issue-demo
(To better see the issue possibly set your phones animation scale to >= 5)
Here is a demo:
Add transitionName to xml layout for the RecyclerView.
The transition animation you see is because of ActivityOptions.makeSceneTransitionAnimation(this#ItemListActivity) and if you add transitionName to the view, it works fine.
Not-too-educated guess
(because I haven't tried and I haven't used Transition Framework in a few months)
The way TF (Transition Framework) works is by computing the start/end values of the transition and performing the animations needed to achieve this.
RecyclerView decorations are not "views" that are part of the layout, so TF has no idea that thing exists. It does know about your RecyclerView of course, because it's contained in the ViewGroup that is animated.
You may have already know this, but in any case, what I think I'd try to do here, is create a custom transition framework transition (they are not hard to do, you can even check TransitionEverywhere and look at how that library implements some missing transitions in the framework); in your CustomTransition, you can then try to interpolate the animation values so the recycler view can redecorate as the animation progresses (like an alpha value that is animated, your custom decorator would "paint" using said alpha).
Now... in truth, I've had to do something similar once, where a custom transition was "driving" a few external views (for reasons at the time) :) but... it was not a RecyclerView item decoration, mine were just "views", so I'm not sure if you can do this this way w/a decoration.
I think it's worth trying.

Why RecyclerView items disappear immediately when using Transition API?

This is a question regarding the use of Android Transition API.
I am trying to animate the height change of a list, just like a dropdown menu.
I tried 2 approaches
Use a RecyclerView and animates its height change
Use a ScrollView > LinearLayout hierarchy and animates ScrollView's height.
The 2nd approach works perfectly.
But the 1st approach has a serious glitch - when the collapse transition starts, items disappear immediately.
By looking at the below GIF you can observe clearly the difference:
To be exact, items' visibility changes at the moment I change RecyclerView's LayoutParams, without waiting for the transition to finish, whatever it is expanding or collapsing
Code
I have created a minimal project on Github.
If you just want to look at the code, here is the MainActivity.
Question
Is it possible to achieve ScrollView's effect with a RecyclerView?
If yes, how?
My Idea is to do the transition of all the recycler view rows individual rather than the whole RecyclerView:
So when collapsing iterate through each ROW of a RecyclerView and do a transition. Remember to check for null if some rows are recycled they may return null. So after that collapse the whole recyclerView.
And like wise for the expanding do the same for the views.
This issue is cause by RecyclerView has many views with it but Scroll View has only one View nested in it.

Shared element transition - animate only the visible part of the shared view

I'm working in an app that is similar to Google Calendar...
There are events and when a user click one, the event grows and
transforms into the detail view.
The shared views (the events) are inside a ScrollView, so at some
point those views may be partially visible.
The problem is that when one partially visible View is selected, the full View
appears above all and then the animation runs.
Here is a capture of the problem:
What can I do to make the Transition take only the visible part of the View to animate it?
This is my transition:
<changeBounds xmlns:android="http://schemas.android.com/apk/res/android">
<arcMotion android:minimumHorizontalAngle="15"
android:minimumVerticalAngle="0"
android:maximumAngle="90"/>
</changeBounds>
Shared elements are drawn on top of the entire view hierarchy. You can disable this by setting Window#setSharedElementsUseOverlay(false) in your Activities, but this will result in undesired effects. More details here and on YouTube.
The better solution is to use shared elements transition between Fragments. More details here.

How do I force RecyclerView to keep its views drawn?

I have fragment in my app that acts as a portal to link to other fragments. The way I implemented this is by simulating a click on the nav drawer, which already handles all the code for switching fragments.
NavigationDrawerAdapter.ViewHolder v = (NavigationDrawerAdapter.ViewHolder) mDrawerList.findViewHolderForAdapterPosition(i);
v.itemView.performClick();
However, I get an error when I try to simulate a click on an item that isn't visible on the RecyclerView's current state. I know this is because RecyclerView only keeps visible views in its array of ViewHolders, but I need the ability to simulate a click on views that aren't in that array.
Yes, I know, I should just refactor my code so that I'm not doing janky things like simulating user clicks on the nav drawer. However, in the interest of time, and an understanding that this nav drawer will never really get incredibly big, as long as there are no other really negative caveats other than memory issues, I think it's the best working solution for the current state of my code.
RecyclerView is intended to recycle Views. If you need to keep Views, use a ScrollView with a vertical LinearLayout.
You can probably scroll RecyclerView, wait for finishing and then simulate clicks. But anyway this whole thing seems wrong.
Have you considered NavigationView?

Scene Transition Flicker

I have a simple view containing a scene root FrameLayout, ListView and a couple of buttons on the bottom.
scene root is used to load and show different scenes, the size changes dynamically depending on the current scene. ListView is set to match_parent in both directions and is positioned behind scene root.
Here's the issue:
If I start a transition using the buttons on the bottom everything works ok, no problem, magic. However, if I transition (✝) to a different scene while scrolling (✝✝) the transition seems to flicker before starting.
It almost looks like the rendering engine fails to load the first frame of the animation before the ListView invalidates the hierarchy due to scrolling.
Thanks for the help ;)
✝ TransitionManager.go(Scene, Transition)
✝✝ I've added a couple of methods to the ListView to allow that
All the Google apps that use Scene Transition that I've seen transit from some item in a ListView to its detail Activity. Since ListView has the convenient behavior of immediately stop the scrolling when touched, such a transition doesn't produce flickering.
So it appears the best thing to do may be to programmatically stop the scrolling before transiting to the new Activity, which is accomplished by the code here.

Categories

Resources