Regarding MotionLayout I have few questions.
First How can we update custom properties. I have read the docs, but their is no way to animate the custom properties with non-jason constraint set.
Second, Since compose recommands using lambdas version of function for animation but motion layout takes progress ht
Third, the progress param which I Pass to MotionLayout is required in child composables; is it good to use this with them or MotionLayout provides any other way.
Suppose I have a function that doesn't have lambda version and I have to animate its some Modifier property like scale; would it be good to use Modifier.composed {} lamda to animate it. Will it perform better.
Related
I'm adding layout animations to my apps using the Transition API and I was naively anticipated that this framework - like any properly designed layout animation engine built on top of existing non-animated layout engine - would implement "as if" behavior, i.e. adding animation should not break existing "non-animated" behavior. Particularly, views which visibility is set to GONE/INVISIBLE should already be non-interactive during transition. Unfortunately, looks like it's not the case with the Transition API: views being animated out retain focus and can be clicked [again] during animation, breaking the internal logic of an Activity/Fragment.
So, I wonder: is this by design or am I missing something? Can it be fixed without disrupting animated view's properties and/or resorting to special "interaction-blocking" wrapper views?
I know there is the animateItemPlacement method for LazyColumn, but in LazyGrid it's marked with internal modifier. In any case, this is not exactly what I need, it doesn't animate the addition/removal of items. Are there ready-made solutions (for example, third-party libraries)?
In Android, I'm doing the new Jetpack compose and trying to figure out the equivalent of sharing a viewpool across recyclerviews.
If an app has multiple recyclerviews with similar content, then you can really speed up performance by sharing the same view pool across your recyclerviews. You can create a view pool, customize it, and then set it to each of the recyclerviews. This is something I'm used to doing.
In Jetpack Compose, instead of recycler view there is LazyColumn or LazyRow. How do I share the views or compositions across different lazy lists?
There's no such functionality available as of the current stable version, i.e., 1.1.1. You can, however, take a look at LazyLayout. It is currently available in the alpha versions of Compose, and can achieve what you require (AFAIK) if the layouts are close to each other. Basically, it will be a single Composable, which you handle the contents of, yourself. If the lists are right next to each other, just create a single LazyLayout, create two lists, add the same source to both, and you're all done. If you want to add some other Composables between lists, you'll need to merge those with this one, and render them inside the lazy layout. That's what the Compose team would likely go with, but you know... well actually you never know.
Is there a way to automatically animate composition changes in a Jetpack Compose #Composable? For instance, if a previously shown widget is removed in a recomposition, can a fade-out animation be applied automatically? I'm thinking something similar to Android View's animateLayoutChanges.
Yes, you can use:
val visible by remember { mutableStateOf(false) }
AnimatedVisibility(visible = visible) {
// Composables Here
}
Or for the specific animation you asked for, surround the Composable (s) with CrossFade
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.