我正在尝试使用动画制作隐藏,并通过检测滑动手势显示toolbar
。它有效,但问题是当toolbar
存在(可见)时,如果你一次又一次地向上滑动。我怎样才能防止这种情况发生?我尝试使用变量来计算每一步,然后在结束时重置,但这也不起作用。帮助我过去这将节省更多的时间我已经被困在这里2周了。
CoreActivity.java
//Swipe Events WebSwipe
WebSwipe = new Swipe(350, 700);
WebSwipe.setListener(new SwipeListener() {
@Override
public void onSwipingLeft(final MotionEvent event) {
}
@Override
public void onSwipedLeft(final MotionEvent event) {
}
@Override
public void onSwipingRight(final MotionEvent event) {
}
@Override
public void onSwipedRight(final MotionEvent event) {
}
@Override
public void onSwipingUp(final MotionEvent event) {
}
@Override
public void onSwipedUp(final MotionEvent event) {
Animation ToolbarGone = AnimationUtils.loadAnimation(CoreActivity.this, R.anim.m_toolbar_gone);
m_Toolbar.startAnimation(ToolbarGone);
}
@Override
public void onSwipingDown(final MotionEvent event) {
}
@Override
public void onSwipedDown(final MotionEvent event) {
Animation ToolbarVisible = AnimationUtils.loadAnimation(CoreActivity.this, R.anim.m_toolbar_visible);
m_Toolbar.startAnimation(ToolbarVisible);
}
});
}
答案 0 :(得分:0)
使用visibility
view
如果visible
不开始动画。
使用animation listeners
,以便将您的观看次数visibility
设置为GONE
答案 1 :(得分:0)
试试这段代码::
添加boolean
以管理滑动手势。
private boolean isSwipeUp=falese;
//Swipe Events WebSwipe
WebSwipe = new Swipe(350, 700);
WebSwipe.setListener(new SwipeListener() {
@Override
public void onSwipingLeft(final MotionEvent event) {
}
@Override
public void onSwipedLeft(final MotionEvent event) {
}
@Override
public void onSwipingRight(final MotionEvent event) {
}
@Override
public void onSwipedRight(final MotionEvent event) {
}
@Override
public void onSwipingUp(final MotionEvent event) {
}
@Override
public void onSwipedUp(final MotionEvent event) {
if(!isSwipeUp)
{
Animation ToolbarGone = AnimationUtils.loadAnimation(CoreActivity.this, R.anim.m_toolbar_gone);
m_Toolbar.startAnimation(ToolbarGone);
isSwipeUp = true;
}
}
@Override
public void onSwipingDown(final MotionEvent event) {
}
@Override
public void onSwipedDown(final MotionEvent event) {
Animation ToolbarVisible = AnimationUtils.loadAnimation(CoreActivity.this, R.anim.m_toolbar_visible);
m_Toolbar.startAnimation(ToolbarVisible);
isSwipeUp = false;
}
});
}