DevBytes: Layout Transitions
Why Stack Overflow recommends it
Stack Overflow users link it when answering how to animate layout changes, enable LayoutTransition.CHANGING, or use animateLayoutChanges instead of hand-coding animations.
Recommended by 6 people across 5 different months, 2013 to 2017.
What it is
A short Android Developers DevBytes episode showing how LayoutTransition gives fade, move and resize animations when children are added to or removed from a ViewGroup, often with one line of code. It also covers the Jelly Bean addition that animates other layout changes, not just adds and removes. A downloadable sample project accompanies it.
What people said
Recommends nfirex · 2013-10 · Stack Overflow · on “CustomView extending RelativeLayout”
It is very strange that you get crash on that line: tv.setLayoutParams(layoutParams); I think you that you get it on that line because created View don't have any LayoutParams (besides, if it RelativeLayout.LayoutParams): layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); I think that you can improve addText() method by this video from DevBytes: [this video] But if you want to make your code work you need to replace your steps like this: TextView tv = new TextView(cx); tv.setText(textParam); tv.setTextColor(Color.WHITE); this.addView(tv); // Programatically created View get LayoutParams when we add it to a ViewGroup RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) tv.g
Recommends frozenkoi · 2013-10 · Stack Overflow · on “Animating fragments transition”
You're looking for layout animations. Check the guide in the Android developer's training guides: [LINK] What you need to do is set android:animateLayoutChanges="true" for the layout (xml or in code). In your case for the ViewGroup that has your fragments (you don't show any code, so I can't give you more details). For more elaborate animations some customization might be necessary. They also have the AndroidDevelopers YouTube channel where they go a bit deeper. This video will help you: [this video]
Recommends Timo Hildén · 2014-03 · Stack Overflow · on “animateLayoutChanges does not work well with nested layout?”
The animateLayoutChanges property makes use of LayoutTransitions , which animate both the layout's children and, from Android 4.0 onward, ancestors in the layout hierarchy all the way to the top of the tree. In Honeycomb, only the layout's children will be animated. See this Android Developers Blog post [LINK] for details. Unfortunately, it seems that there's currently no simple way to have the siblings of a layout react to its LayoutTransitions . You could try using a TransitionListener to get notified when the layout's bounds are being changed, and move the sibling views accordingly using Animators. See Chet Haase's second answer in this Google+ post [LINK] . EDIT - Turns out there is a wa
Recommends gdaramouskas · 2015-02 · Stack Overflow · on “How can I make the movement of my cardviews smoother?”
In order to have a smoother movement of your CardViews within your FrameLayout you are going to use the animation package [LINK] to animate your views or their properties. There are many ways to achieve this but the Property Animation [LINK] is by far the simplest way to go. And it certainly fits your needs, since you mention that the movement that interests you is a left to right movement. You can animate the CardView s to move smoother to the y axis . Read carefully this [LINK] document in order to perform what you wish. Edit : Probably LayoutTransition [LINK] will be of use to you. Check out this [this video] video to see what is it about. In short when you add/remove views in your ViewGroup,
Recommends tachyonflux · 2015-04 · Stack Overflow · on “android:animateLayoutChanges won't work in parent layout”
API 16 added the LayoutTransition.CHANGING animation type, however it is disabled by default. To enable: LinearLayout linearLayout = (LinearLayout) findViewById(R.id.main); linearLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING); Nice DevBytes video: [this video]
Recommends Sergey Shevchenko · 2015-10 · Stack Overflow · on “¿How make the correct animation? (Android java without xml)”
For animation of changes on a layout you can set animateLayoutChanges="true" to ViewGroup item. And any changes will be animated with default animation. If you want to change the animation behavior you can set to ViewGroup your oun LayoutTransition object. Here google talks video [this video] which can help you, I hope )
Cites user1889890 · 2013-05 · Stack Overflow · on “How do I create child views with elements inside?”
I came across this video [this video] by google that demonstrated animated transitions with the creation of child views by using onClick to add or remove the child view. As part of the learning process: I took the code, broke it down, and made some changes (I am not a copy and paste programmer). My question is: How do I add a TextView , Button and other various elements to the child view when it is created? (Project download from google if you're interested: full project [LINK] ) Here is what I have in my activity: /** * Custom view painted with a random background color and two different sizes which are * toggled between due to user interaction. */ public class ColoredView extends View { private
Cites Xaver Kapeller · 2015-03 · Stack Overflow · on “Animated Views move outside of my layout”
When you perform translation animations on Views then those Views don't really move inside the layout. Its just visual for the User, but when it comes to layouting and/or measuring than any translation values are ignored. It is always as if the Views are not translated at all. What I am guessing you are doing right now is this: You react to the click event and expand the View you want to expand. You calculate how much the other Views need to move to accommodate the expanded View . Then you perform translate animations on those Views by much they need to move. And then as a result suddenly a few Views move off screen. This approach can actually never work. You always need to remember that a V
Cites alenz316 · 2015-04 · Stack Overflow · on “Animate changing LayoutParams (RelativeLayout)”
To explicitly animate in this case, your sleepRoom() should look like this. public void sleepRoom(View view) { final RelativeLayout sr = (RelativeLayout) view; RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sr.getLayoutParams(); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.MATCH_PARENT; sr.setLayoutParams(params); PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1); PropertyValu
Cites Variag · 2017-05 · Stack Overflow · on “How to animate LayoutParams x and y in Android”
The easiest solution I've found to similar problem is shown here: [this video] In my case I have a RelativeLayout and want to change its android:layout_below value programmatically (it's parent is also RelativeLayout ). So in onCreate I've put: LayoutTransition layoutTransition = rlListLayout.getLayoutTransition(); layoutTransition.enableTransitionType(LayoutTransition.CHANGING); and then for example in onClick method changed layout params: RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) rl.getLayoutParams(); params.addRule(RelativeLayout.BELOW, R.id.dummy); rl.setLayoutParams(params); That's it. 5 lines of code and no need to calculate position nor measure anything.