这不起作用,我想知道为什么。什么都没有显示但是如果我在// sleep
之后删除了所有内容,那么视图就会显示动画,但当然它不会再隐藏......
任何建议都会受到质疑。这发生在一个适配器内,并假设弹出一个TextView
说“登录为:your@gmail.com”
Application.getInstance().runOnUiThreadDelay(new Runnable() {
@Override
public void run() {
// Prepare the View for the animation
view.setVisibility(View.VISIBLE);
view.setAlpha(0.0f);
// show view
view.animate()
.translationY(view.getHeight())
.alpha(1.0f)
.setDuration(500);
// sleep
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// hide view
view.animate()
.translationY(0)
.alpha(0.0f)
.setDuration(500)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
view.setVisibility(View.GONE);
}
});
}
}, 500);
视图
<TextView
android:id="@+id/popup_logged_in"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="gone"
android:text="logged in as wdkejhedwedrwdeklj"
android:padding="15dp"
android:textSize="14sp"
android:textAllCaps="true"
android:textStyle="bold" />