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);
怎么做?
答案 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) {
}
});