我在开始时隐藏了一个视图(它是可见的,但在屏幕下方,因此用户看不到它),并且第一次用户单击标记时,视图会随着动画和用户可以看到它。当用户点击其他标记时,视图应该向下移动(隐藏在屏幕下方的原始位置),然后更改它所具有的TextView的文本,并最终再次使用新信息移动它。其中一个动画不起作用
一切正常,但下来的动画;视图正在消失,并再次进行上移。我曾尝试使用Animation和TranslateAnimation获得相同的结果。
这里是我的代码:
@Override
public boolean onMarkerClick(Marker marker) {
if (!anyMarkerSelected) {
textViewNombre.setText(establecimiento.getNombreEstablecimiento());
textViewDireccion.setText(establecimiento.getNombreVia());
textViewDescripcion.setText(establecimiento.getNumeroVia());
view.startAnimation(animationUp);
animationUp.setFillAfter(true);
mapa.animateCamera(CameraUpdateFactory.newLatLng(marker.getPosition()));
anyMarkerSelected = true;
return true;
} else {
view.startAnimation(animationDown); //This animation is not working
animationDown.setFillAfter(true);
textViewNombre.setText(establecimiento.getNombreEstablecimiento());
textViewDireccion.setText(establecimiento.getNombreVia());
textViewDescripcion.setText(establecimiento.getNumeroVia());
view.startAnimation(animationUp);
animationUp.setFillAfter(true);
return true;
}
}
而且动画的XML文件是:
<translate
android:duration="200"
android:fromXDelta="0"
android:toYDelta="110%" />
<translate
android:duration="200"
android:fromXDelta="0"
android:toYDelta="-110%" />
什么建议吗?
也许只需拨动从View.GONE能见度View.VISIBLE? – 2014-09-24 22:03:00
视图并没有真正消失或看不见,它只是在屏幕之外(但仍然是View.VISIBLE) – moictab 2014-09-24 22:04:47