我使用horizontalscrollView连同动画来移动一组图像作为幻灯片。我可以使用以下代码将图像从右向左移动:
public void getScrollMaxAmount(){
int actualWidth = (horizontalOuterLayout.getMeasuredWidth()-512);
scrollMax = actualWidth;
}
public void startAutoScrolling(){
if (scrollTimer == null) {
scrollTimer = new Timer();
final Runnable Timer_Tick = new Runnable() {
public void run() {
moveScrollView();
}
};
if(scrollerSchedule != null){
scrollerSchedule.cancel();
scrollerSchedule = null;
}
scrollerSchedule = new TimerTask(){
@Override
public void run(){
runOnUiThread(Timer_Tick);
}
};
scrollTimer.schedule(scrollerSchedule, 30, 30);
}
}
public void moveScrollView(){
scrollPos = (int) (horizontalScrollview.getScrollX() + 1.0);
if(scrollPos >= scrollMax){
scrollPos = 0;
}
horizontalScrollview.scrollTo(scrollPos, 0);
}
我现在想将图像从右到左移动为幻灯片。我找不到正确的公式/逻辑。请帮助我。:(