Android 动画结束后更新TextView
我正在尝试将动画添加到我的线性布局中。下面是我的代码:-Android 动画结束后更新TextView,android,android-animation,textview,Android,Android Animation,Textview,我正在尝试将动画添加到我的线性布局中。下面是我的代码:- <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/mylinearlayout" android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mylinearlayout"
android:weightSum="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
android:layout_weight="0.5"
android:src="@mipmap/ic_launcher"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/offerImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:layout_weight="0.5"
android:layout_gravity="center_horizontal"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/startAnimation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/offerImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:layout_weight="0.5"
android:layout_gravity="center_horizontal"
android:text="Start"
/>
</LinearLayout>
</LinearLayout>
我可以看到动画的发生,但动画之后,tv_数据文本视图不会更改为“动画之后”
请帮助设置动画对象上的AnimationListener:
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd (Animation animation) {
showData();
}
@Override
public void onAnimationRepeat (Animation animation) {}
@Override
public void onAnimationStart (Animation animation) {}
});
另外,如果希望立即启动,请使用
ll\u mainLayout
上的startAnimation()
而不是setAnimation()
。:-尝试回答。。但它不起作用。。。。我还看不到更新的文本视图…在调用startAnimation()
之前,您是否尝试过设置AnimationListener?
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd (Animation animation) {
showData();
}
@Override
public void onAnimationRepeat (Animation animation) {}
@Override
public void onAnimationStart (Animation animation) {}
});