答案 0 :(得分:2)
public void hideView(final View view) {
view.animate()
.translationY(view.getHeight()+YOUR MARGIN)
.setDuration(300)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
});
}
public void showView(final View view) {
view.animate()
.translationY(0)
.setDuration(300)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
});
}
<强>编辑:强>
for i sec等待来自:
handler.postDelayed(new Runnable(){
@Override
public void run() {
showView(...)
}
}, 1000);
您可能必须在运行中使用runOnUiThread(new Runnable(...))
重新编辑:
public void hideView(final View view) {
view.animate()
.translationY(-10)
.setDuration(30)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
view.animate()
.translationY(view.getHeight()+YOUR MARGIN + 10)
.setDuration(300)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
});
}
});
}