I am creating linearLayouts programmatically and would like them to fade in and out when the visibility is set to visible/gone.
I can set
android:animateLayoutChanges="true"
in the xml-file, but since I am creating the views programmatically, I need to set it programmatically. How can I do that?
Use this code:
container.setLayoutTransition(new LayoutTransition());
or
LayoutTransition lt = new LayoutTransition(); lt.disableTransitionType(LayoutTransition.DISAPPEARING); container.setLayoutTransition(lt);
To disable the fade-out effect try this:
LinearLayout layout = (LinearLayout) findViewById(R.id.test_layout); layout.setLayoutTransition(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With