我顺利滚动到定义的位置。
smoothScrollTo(0, 1000);
执行此方法后 - 我会执行一些操作。但我想做它们 - 滚动动画结束后。
我想检测滚动动画何时结束。我怎么能这样做?
答案 0 :(得分:2)
我这样做了,
final ScrollView mScrollView = (ScrollView) findViewById(R.id.scrollview);
layoutSponsorBax.setVisibility(View.VISIBLE);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
ViewGroup relativeL = (ViewGroup) mScrollView
.getChildAt(mScrollView.getChildCount() - 1);
final int sVH = mScrollView.getBottom()
- mScrollView.getTop();
View notePad = relativeL.getChildAt(2);
final int svHeight = 800;
Log.i("svHeight", "svHeight : " + svHeight);
final float duration = 2000;
ctt = new CountDownTimer((int) duration, 1) {
int temp = 0;
public void onTick(long millisUntilFinished) {
try {
Log.i("millisUntilFinished",
"millisUntilFinished : "
+ millisUntilFinished);
Log.i("Height- Temp", "Temp : " + temp);
mScrollView.scrollTo(0, temp);
temp = (int) (((svHeight) - (millisUntilFinished / duration)
* (svHeight)));
} catch (ArithmeticException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public void onFinish() {
}
}.start();
}
});
}
};
int duration = 1400;
timer.schedule(task, duration);
请检查这可能对您有所帮助