我在開始時隱藏了一個視圖(它是可見的,但在屏幕下方,因此用戶看不到它),並且第一次用戶單擊標記時,視圖會隨着動畫和用戶可以看到它。當用戶點擊其他標記時,視圖應該向下移動(隱藏在屏幕下方的原始位置),然後更改它所具有的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