Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: animateLayoutChanges="true", what can I do if the fade-out effect is unwanted?

in my layout XML file:

<LinearLayout
   ...
   animateLayoutChanges="true"
   ... />

When I add and a View and to this layout and delete it, I can see both fade in and fade out effect. However, I need only the fade in effect. Could anyone tell me what I should do?

like image 572
nomnom Avatar asked Nov 13 '13 01:11

nomnom


1 Answers

You should remove animateLayoutChanges from layout XML file. Instead, create a LayoutTransition object at runtime and supply it to the layout with the setLayoutTransition() method.

private ViewGroup mContainerView;  

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.custom_linear_layout);

    mContainerView = (ViewGroup) findViewById(R.id.container);
    LayoutTransition lt = new LayoutTransition();
    lt.disableTransitionType(LayoutTransition.DISAPPEARING);
    mContainerView.setLayoutTransition(lt);
}
like image 131
Infinite Recursion Avatar answered Oct 30 '22 17:10

Infinite Recursion