1
Я пытаюсь добавить анимацию в свой линейный макет. Ниже мой код: -Обновление TextView после окончания анимации Android
<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>
Внутри метода OnCreate моей деятельности, я люблю
@Override
protected void onCreate(Bundle savedInstanceState) {
.
.
.
LinearLayout ll_mainLayout = (LinearLayout)findViewById(R.id.mylinearlayout);
TextView tv_data = (TextView) findViewById(R.id.textView1);
Button btn_startAnimation = (Button)findViewById(R.id.startAnimation);
tv_data.setText("Before Animation");
btn_StartAnimation.setOnClickListner(new View.OnClickListener(){
@Override
public void OnClick(View v)
{
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.move);
ll_mainLayout.setAnimation(animation);
ll_mainLayout.setLayoutAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
showData();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
});
}
public void showData()
{
tv_data.setText("After Animation");
}
}
я могу увидеть анимацию происходит, но после анимации tv_data TextView не меняется на «После анимации «;
Пожалуйста, помогите
: - попробовал ответить .. но он не работает .... я еще не вижу обновленного текстового вида ... –
Вы пытались установить AnimationListener * перед тем, как вы вызываете 'startAnimation()'? – patloew