【发布时间】:2020-07-27 14:37:23
【问题描述】:
我有一个垂直线性布局,它有两个 textview,我在第一个 textview 中添加了 textsize 动画 所以问题是当文本视图更大并且每当在上部文本视图中添加新行时,下部文本视图只会向下移动而没有动画。它只是从以前的位置弹出并在新位置弹出。当第一个 textview 高度改变时,如何为第二个 textview 设置动画?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/one"
android:text="one two three four five"
android:textSize="@dimen/TEXT_SIZE_18"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/two"
android:text="six seven eight nine ten"
android:textSize="@dimen/TEXT_SIZE_18"/>
</LinearLayout>
我用动画一个文本视图大小
final float startSize = 18; // Size in pixels
final float endSize = 24;
long animationDuration = 600; // Animation duration in ms
ValueAnimator animator = ValueAnimator.ofFloat(startSize, endSize);
animator.setDuration(animationDuration);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedValue = (float) valueAnimator.getAnimatedValue();
if (one!=null){
one.setTextSize(animatedValue);
}
}
});
我想让两个文本视图自动动画
【问题讨论】:
-
添加带有问题的代码。
-
我已添加代码请帮助@ADM
-
我已经添加了一个答案,它在我的最后工作,看看是否适合你。
标签: android animation transition