Backbone.geppetto 如何同时移动两个标记?
我正试图用ObjectAnimator和AnimatorSet同时移动两个标记,但我无法让它工作,在这里我分享了我正在使用的代码Backbone.geppetto 如何同时移动两个标记?,backbone.geppetto,Backbone.geppetto,我正试图用ObjectAnimator和AnimatorSet同时移动两个标记,但我无法让它工作,在这里我分享了我正在使用的代码 handler =new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { if (list.size() > 1 ){ if (in
handler =new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (list.size() > 1 ){
if (index < list.size() - 1) {
index++;
next = index + 1;
}
if (index < list.size() - 1) {
starposition = list.get(index);
endposition = list.get(next);
}
if (index2 < list2.size() - 1) {
index2++;
next2 = index2 + 1;
}
if (index2 < list2.size() - 1) {
starposition2 = list2.get(index2);
endposition2 = list2.get(next2);
}
final ObjectAnimator objectAnimator= ObjectAnimator.ofFloat(marker,"rotation",0,1);
objectAnimator.setInterpolator(new LinearInterpolator());
objectAnimator.setDuration(2000);
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
v = objectAnimator.getAnimatedFraction();
logg = v * endposition.longitude + (1 - v)
* starposition.longitude;
latt = v * endposition.latitude + (1 - v)
* starposition.latitude;
LatLng newpos = new LatLng(latt, logg);
marker.setPosition(newpos);
marker.setAnchor(0.5f, 0.5f);
marker.setRotation(getBearing(starposition, newpos));
}
});
final ObjectAnimator objectAnimator2= ObjectAnimator.ofFloat(marker,"rotation",0,1);
objectAnimator2.setInterpolator(new LinearInterpolator());
objectAnimator2.setDuration(2000);
objectAnimator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
h = objectAnimator2.getAnimatedFraction();
logg2 = h * endposition2.longitude + (1 - h)
* starposition2.longitude;
latt2 = h * endposition2.latitude + (1 - h)
* starposition2.latitude;
LatLng newpos2 = new LatLng(latt2,logg2);
marker2.setPosition(newpos2);
marker2.setAnchor(0.5f, 0.5f);
marker2.setRotation(getBearing(starposition2, newpos2));
}
});
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(objectAnimator,objectAnimator2);
animatorSet.start();
handler.postDelayed(this, 3000);
}
}
},3000);
handler=newhandler();
handler.postDelayed(新的Runnable(){
@凌驾
公开募捐{
如果(list.size()>1){
如果(索引
我有两个列表,其中存储每个标记的LatLngs,然后创建Objectanimator为每个标记提供动画,但是。。。当我运行它时,两个不同时移动,而是按顺序移动,当第一个结束时,另一个开始移动