如何在Scroll上从屏幕底部滑动/滑动布局?
问题描述:
我需要在滚动时向下滑动布局,并在滚动停止时向上滑动。我试着用下面的代码去做 ,但是面临一些问题。问题是,当我第一次滚动,它完美的作品。如何在Scroll上从屏幕底部滑动/滑动布局?
但是,当我尝试再次滚动,动画做的工作,它有点闪烁。 附上下面的代码。
请让我知道我要去哪里错了。
scrollviewDetails =(ScrollView)fragmentView.findViewById(R.id.sv_details); scrollviewDetails .setOnTouchListener(新View.OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL:
case MotionEvent.ACTION_MOVE:
Log.e("SCROLL", "ACTION_SCROLL slidingDown==" +slidingDown);
if(!slidingDown){
flActionNow.clearAnimation();
slidingDown = true;
slidingUp = false;
flActionNow.setAnimation(slideDown);
}
break;
case MotionEvent.ACTION_DOWN:
Log.e("SCROLL", "ACTION_DOWN");
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
Log.e("SCROLL", "SCROLL_STOP slidingUp==" +slidingUp);
if(!slidingUp){
flActionNow.clearAnimation();
slidingUp = true;
slidingDown = false;
flActionNow.setAnimation(slideUp);
}
break;
}
return false;
}
});
滑下ANIM:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fillAfter="true"
android:fromYDelta="0%p"
android:toYDelta="100%p" />
</set>
向上滑动ANIM:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fillAfter="true"
android:fillBefore="true"
android:fromYDelta="75%p"
android:toYDelta="0%p" />
</set>
谢谢, 斯纳
答
甲愚蠢的错误我做了!使用startAnimation而不是se动画工作! :)