Android 横向模式下的怪异动画行为

Android 横向模式下的怪异动画行为,android,animation,Android,Animation,我有一个列表片段(support.v4),它只显示一个列表视图。单击某个元素时,该元素上的动画将启动。动画在\u 1.xml中的文件夹\u animation\u中定义(关于动画的进一步解释见底部的屏幕截图): 只要方向是纵向的,这就行了。一旦方向改变为横向模式,我就会有一种我不理解的奇怪行为。单击的元素突然移动到ListView中最后可见的位置。现在动画从这里开始。 我还设置了一个平板电脑仿真器,以便在横向环境中真正启动该应用程序,因为我认为由于方向改变本身可能会出现问题。但这种行为根本没有改

我有一个列表片段(support.v4),它只显示一个列表视图。单击某个元素时,该元素上的动画将启动。动画在\u 1.xml中的文件夹\u animation\u中定义(关于动画的进一步解释见底部的屏幕截图):

只要方向是纵向的,这就行了。一旦方向改变为横向模式,我就会有一种我不理解的奇怪行为。单击的元素突然移动到ListView中最后可见的位置。现在动画从这里开始。
我还设置了一个平板电脑仿真器,以便在横向环境中真正启动该应用程序,因为我认为由于方向改变本身可能会出现问题。但这种行为根本没有改变。还是一样的问题

谢谢你的帮助


更新: 我使用以下代码进行了一些测试:

public void onListItemClick(final ListView l, final View v, final int position, long id) {
    super.onListItemClick(l, v, position, id);

    Rect rect = new Rect();
    v.getDrawingRect(rect);
    int[] coord = new int[2];
    v.getLocationOnScreen(coord);
    Log.e(tag, "ListView-item: left: " + rect.left + ", right: "  + rect.right+ ", top: " + rect.top + ", bottom: " +  rect.bottom + ", Pos on Screen: " + coord[0] + ", " + coord[1]);

    View last = l.getChildAt(l.getLastVisiblePosition() - l.getFirstVisiblePosition());
    last.getDrawingRect(rect);
    last.getLocationOnScreen(coord);
    Log.e(tag, "ListView-item: left: " + rect.left + ", right: "  + rect.right+ ", top: " + rect.top + ", bottom: " +  rect.bottom + ", Pos on Screen: " + coord[0] + ", " + coord[1]);

    Animation expandAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.folder_animation_in_1);
    v.bringToFront();
    v.setBackgroundColor(Color.BLACK);
    v.setAnimation(expandAnim);         
    v.startAnimation(expandAnim);
    v.postDelayed(new Runnable() {

        @Override
        public void run() {
            Rect rect = new Rect();
            v.getDrawingRect(rect);
            int[] coord = new int[2];
            v.getLocationOnScreen(coord);
            Log.e(tag, "ListView-item: left: " + rect.left + ", right: "  + rect.right+ ", top: " + rect.top + ", bottom: " +  rect.bottom + ", Pos on Screen: " + coord[0] + ", " + coord[1]);
        }
    }, animationDuration);
}
给定测试的输出为:

ListView-item: left: 0, right: 683, top: 0, bottom: 100, Pos on Screen: 0, 269
ListView-item: left: 0, right: 683, top: 0, bottom: 100, Pos on Screen: 0, 677
ListView-item: left: 0, right: 683, top: 0, bottom: 100, Pos on Screen: 0, 677
我不确定这些信息有多大帮助,但它支持效果的视觉感知-我真的认为ListView的给定元素被放置在动画开始之前的最后一个可见位置。但是为什么呢


正确的动画行为


横向模式下的动画行为

public void onListItemClick(final ListView l, final View v, final int position, long id) {
    super.onListItemClick(l, v, position, id);

    Rect rect = new Rect();
    v.getDrawingRect(rect);
    int[] coord = new int[2];
    v.getLocationOnScreen(coord);
    Log.e(tag, "ListView-item: left: " + rect.left + ", right: "  + rect.right+ ", top: " + rect.top + ", bottom: " +  rect.bottom + ", Pos on Screen: " + coord[0] + ", " + coord[1]);

    View last = l.getChildAt(l.getLastVisiblePosition() - l.getFirstVisiblePosition());
    last.getDrawingRect(rect);
    last.getLocationOnScreen(coord);
    Log.e(tag, "ListView-item: left: " + rect.left + ", right: "  + rect.right+ ", top: " + rect.top + ", bottom: " +  rect.bottom + ", Pos on Screen: " + coord[0] + ", " + coord[1]);

    Animation expandAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.folder_animation_in_1);
    v.bringToFront();
    v.setBackgroundColor(Color.BLACK);
    v.setAnimation(expandAnim);         
    v.startAnimation(expandAnim);
    v.postDelayed(new Runnable() {

        @Override
        public void run() {
            Rect rect = new Rect();
            v.getDrawingRect(rect);
            int[] coord = new int[2];
            v.getLocationOnScreen(coord);
            Log.e(tag, "ListView-item: left: " + rect.left + ", right: "  + rect.right+ ", top: " + rect.top + ", bottom: " +  rect.bottom + ", Pos on Screen: " + coord[0] + ", " + coord[1]);
        }
    }, animationDuration);
}
ListView-item: left: 0, right: 683, top: 0, bottom: 100, Pos on Screen: 0, 269
ListView-item: left: 0, right: 683, top: 0, bottom: 100, Pos on Screen: 0, 677
ListView-item: left: 0, right: 683, top: 0, bottom: 100, Pos on Screen: 0, 677