【发布时间】:2017-08-10 13:03:07
【问题描述】:
我有 3 个文本视图,代表属于 3 个类别的信息。我还有 3 个其他文本视图代表每个类别的标题。
这些文本视图相互约束(文本视图A标题被约束在文本视图A信息之上,文本视图B标题被约束,文本视图B信息被约束)。看起来像这样:
我已经写了代码,这样当一个Text View的标题被点击时,对应的Text View信息会向下滑动并显示信息。
我的问题是,例如,当文本视图 B 信息填充数据时,文本视图 C 标题出现在文本视图 B 信息即将结束的位置,但在突然而生涩的运动中(文本的顺序意见仍然正确,这是我不想要的生涩动作)。 2秒后(slide_down的时间)Text View B信息被填满,在Text View C标题上方长毛绒:
同样,当再次单击标题时,会触发 scroll_up,但文本视图 C 标题直接出现在传送中的文本视图 B 信息下方。然后发生滑动,文字经过Text View C Title:
有没有什么办法可以让正在滑动的 Text Viewing 下面的 Text View 在上滑或下滑的滑动动作中被推动,而不是正在发生的这种瞬移?
我一直在摆弄代码有一段时间了,我被卡住了。
调用动画的方法:
public void ShowWeekly(View view) {
if(WeeklyTextView.isShown()){
slide_up(this, WeeklyTextView);
WeeklyTextView.setVisibility(View.GONE);
}
else{
WeeklyTextView.setVisibility(View.VISIBLE);
slide_down(this, WeeklyTextView);
}
}
slide_up xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
android:fillAfter="false">
<scale
android:duration="2000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/test"
android:toXScale="0.0"
android:toYScale="0.0" />
Slide_down xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
android:fillAfter="true">
<scale
android:duration="200"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="1.0" />
文本视图位于滚动视图内的约束布局中。以下是文本视图:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:id="@+id/scroll"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/OverallButton">
<android.support.constraint.ConstraintLayout
android:id="@+id/constraint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/OverallButton"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:id="@+id/OverallTextView"
android:text="Overall Statistics\n"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="parent"
android:onClick="ShowDistance"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/OverallTextViewContent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/OverallTextView"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Weekly Statistics\n"
android:textSize="20dp"
android:id="@+id/WeeklyTextView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/OverallTextViewContent"
android:onClick="ShowWeekly"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/WeeklyTextViewContent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/WeeklyTextView"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Best Statistics\n"
android:textSize="20dp"
android:id="@+id/BestTextView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/WeeklyTextViewContent"
android:onClick="ShowBest"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/BestTextViewContent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/BestTextView"
/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
【问题讨论】:
标签: android animation textview fadein fadeout