1

我已经在我的活动之间实现了转换,问题是当转换发生时,第一个活动的内容在第二个活动上显示一毫秒,然后它消失,显示第二个活动的内容,我该如何摆脱并顺利展示第二个活动?

动画输入:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate android:fromXDelta="0%" android:toXDelta="-100%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200"
        />
</set>

动画离开:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="100%" android:toXDelta="0%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200"
        />
</set>

这就是我所说的:

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                TextView clienteId = (TextView) view.findViewById(R.id.pedidoID);


                Intent intent = new Intent(getActivity(), PedidoDetalheActivity.class);
                intent.putExtra("id_pedido", clienteId.getText()); // envia o id do pedido para a tela de detalhes


                startActivity(intent);
                getActivity().overridePendingTransition(R.anim.animation_enter, R.anim.animation_leave);

            }


        });
4

1 回答 1

1

因此,要使您的动画正常工作,您必须执行以下操作:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate android:fromXDelta="100%" android:toXDelta="0%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200"
        />
</set>

这意味着活动将从左侧 (100%) 进入并停止在其初始位置 (0%)

至于离开动画:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="0%" android:toXDelta="-100%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200"
        />
</set>

这意味着当前可见活动将从当前位置 (0%) 离开屏幕到右侧 (-100%)

于 2014-10-21T10:21:17.420 回答