Я знаю, что этот тип вопросов задавался многими людьми, просто смотрят на мой код и мою проблему.
Я раздуваю текстовое представление внутри linearLayout этим методом, и он работает нормально.
private void inflateTextView(String name) {
TextView tv = (TextView) getLayoutInflater().inflate(R.layout.category_text_view, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(10, 0, 0, 10);
tv.setText(name);
tv.setLayoutParams(params);
tv.setOnClickListener(this);
category_container.addView(tv);
}
![enter image description here](https://i.stack.imgur.com/B8ULS.jpg)
Теперь я хочу, чтобы, когда пользователь щелкает конкретное текстовое представление, оно удаляется с анимацией, а удаляемая часть также работает отлично.Но когда я удаляю определенный текстовый вид, другие предыдущие раздутые текстовые видения не говорят о своем месте.При использовании этого метода кажется, что он работает только с частью прорисовки, фактический вид не удаляется.
ObjectAnimator animX = ObjectAnimator.ofFloat(textView, View.SCALE_X, 0f);
ObjectAnimator animY = ObjectAnimator.ofFloat(textView, View.SCALE_Y, 0f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.setDuration(500);
animSetXY.start();
![enter image description here](https://i.stack.imgur.com/0oQXF.jpg)
Но когда я используюстарый класс с прослушивателем анимации, представление которого внезапно удаляется (конечно, будет), но я хочу, чтобы оно было гладким.
if (goAnimation == null) {
goAnimation = new ScaleAnimation(
1f, 0f, // Start and end values for the X axis scaling
1f, 0f, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_SELF, 0.5f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, 0.5f); // Pivot point of Y scaling
goAnimation.setFillAfter(false); // Needed to keep the result of the animation
goAnimation.setDuration(300);
}
textView.startAnimation(goAnimation);
goAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
textView.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});