我正在为某些视图进行动画转换,然后遇到一个问题:子视图不会从其父视图获得动画效果,它们只是显示在动画结束阶段结束时的动画。感谢您的建议,我是否想念一些非常重要的东西。
JAVA
private void hideAlertSelect(){
int height = panelAlertSelect.getLayoutParams().height;
TranslateAnimation animate = new TranslateAnimation(
0, // fromXDelta
0, // toXDelta
0, // fromYDelta
-height); // toYDelta
animate.setDuration(TRANSLATE_DURATION);
animate.setFillAfter(true);
animate.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
panelAlertSelect.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
panelAlertSelect.startAnimation(animate);
}
XML
<RelativeLayout
android:id="@+id/panelAlertSelect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
>
<com.mikepenz.iconics.view.IconicsImageView
android:layout_alignParentLeft="true"
android:layout_width="24dp"
android:layout_height="24dp"
app:iiv_color="@color/grey_500"
app:iiv_icon="cmd_bell_ring"
/>
<android.support.v7.widget.AppCompatTextView
android:layout_alignParentRight="true"
android:layout_marginLeft="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remind me"
android:textColor="@color/grey_500"
/>
</RelativeLayout>