如何处理布局动画的结束

时间:2014-09-25 10:29:52

标签: android android-layout

animateLayoutChanges的布局如下所示:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/main_layout"
    android:orientation="vertical"
    android:animateLayoutChanges="true">

    <Button
        layout_width="wrap_content"
        layout_height="wrap_content"
        android:id="@+id/button"/>    
</LinearLayout>

我想处理setVisibility aniamtion加入的那一刻:

buttom.setVisibility(View.GONE);

怎么做?

1 个答案:

答案 0 :(得分:4)

您可以使用LayoutTransition及其监听器

LayoutTransition mainLayoutTransition = mainLayout.getLayoutTransition();
mainLayoutTransition.addTransitionListener(new TransitionListener(){

    @Override
    public void endTransition(LayoutTransition arg0, ViewGroup arg1,
                    View arg2, int arg3) {
        button.setVisibility(View.GONE);
    }

    @Override
    public void startTransition(LayoutTransition transition,
                    ViewGroup container, View view, int transitionType) {

    }
});