Android视图在视觉上处于正常位置,但实际上处于TranslateImation之后的起始位置
我有3个水平拖动视图。例如,如果我将第一个放置在第二个上,则第二个和第三个必须向右移动。 初始位置: 守则:Android视图在视觉上处于正常位置,但实际上处于TranslateImation之后的起始位置,android,android-animation,android-4.0-ice-cream-sandwich,android-4.2-jelly-bean,Android,Android Animation,Android 4.0 Ice Cream Sandwich,Android 4.2 Jelly Bean,我有3个水平拖动视图。例如,如果我将第一个放置在第二个上,则第二个和第三个必须向右移动。 初始位置: 守则: case DragEvent.ACTION_DROP: targetIndex = ((ViewInfo) targetView.getTag()).index; int lastIndex = getChildCount() - 1; droppedView = (View) event.
case DragEvent.ACTION_DROP:
targetIndex = ((ViewInfo) targetView.getTag()).index;
int lastIndex = getChildCount() - 1;
droppedView = (View) event.getLocalState();
droppedIndex = ((ViewInfo) droppedView.getTag()).index;
if (droppedView == this) {
return false;
}
for (int i = targetIndex; i <= lastIndex; i++) {
if (getChildAt(i) != droppedView) {
moveChildToRight(i);
}
}
private void moveChildToRight(int index) {
....
TranslateAnimation anim = new TranslateAnimation(0, 200, 0, 0);
anim.setDuration(1000);
anim.setFillAfter(true);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
Log.d(TAG, "Animation ended");
requestLayout();
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
});
child.startAnimation(anim);
}
case DragEvent.ACTION\u DROP:
targetIndex=((ViewInfo)targetView.getTag()).index;
int lastIndex=getChildCount()-1;
droppedView=(视图)event.getLocalState();
droppedIndex=((ViewInfo)droppedView.getTag()).index;
如果(droppedView==此){
返回false;
}
对于(inti=targetIndex;i我知道这已经有一年多的历史了,但我会回答,以防其他人找到该页面
这是如何翻译动画(查看动画)工作。它可以直观地移动对象,但不会更新“实际X/Y”属性。例如,如果您的视图是按钮,则在原始区域中触摸将显示在按钮可视位置的单击,但在看到按钮的位置单击将不会起任何作用,因为实际按钮从未移动过。我意识到这已经超过一年了ld,但我会回答,以防其他人找到该页面
这是如何翻译动画(查看动画)工作。它可以直观地移动对象,但不会更新“实际X/Y”属性。例如,如果视图是按钮,则在原始区域中触摸将显示在按钮可视位置的单击,但在看到按钮的位置单击将不会起任何作用,因为实际按钮从未移动