Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 片段转换的动画渲染不正确_Android_Eclipse_Animation_Android Fragments_Android Transitions - Fatal编程技术网

Android 片段转换的动画渲染不正确

Android 片段转换的动画渲染不正确,android,eclipse,animation,android-fragments,android-transitions,Android,Eclipse,Animation,Android Fragments,Android Transitions,我在我的布局中使用了一个片段,我希望为片段提供滑入、滑出动画 这就是我的片段的样子 <fragment android:id="@+id/fragment_place" android:name="com.mainpackage.FragmentOne" android:layout_width="match_parent" android:layout_height="wrap_cont

我在我的布局中使用了一个片段,我希望为片段提供滑入、滑出动画

这就是我的片段的样子

 <fragment
            android:id="@+id/fragment_place"


            android:name="com.mainpackage.FragmentOne"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true" />

您应该使用框架布局作为容器,并通过编程设置片段

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/container"
    tools:context="com.wework.mobile.v2.activities.help.FailRequestFragment">
因此,是的,您应该使用FrameLayout而不是布局中的固定片段,并将片段以编程方式放入布局中

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
        android:interpolator="@android:interpolator/decelerate_quint"
        android:valueFrom="0dp" android:valueTo="1000dp"
        android:valueType="floatType"
        android:propertyName="translationX"
        android:duration="@android:integer/config_shortAnimTime" />


</set>
FragmentManager fm = getFragmentManager();
         FragmentTransaction fragmentTransaction = fm.beginTransaction();



         if(oldt!=t)
         {  fragmentTransaction.setCustomAnimations(R.anim.slide_in, R.anim.slide_out);
         oldt=t;
         }
         else
         {
             fragmentTransaction.setCustomAnimations(R.anim.none, R.anim.none);
         }
         fragmentTransaction.replace(R.id.fragment_place, fr);
         fragmentTransaction.commit();
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/container"
    tools:context="com.wework.mobile.v2.activities.help.FailRequestFragment">
final FragmentTransaction transaction = fragmentManager.beginTransaction();

        // Replace whatever is in the container view with this
        // fragment, and add the transaction to the back stack so the user
        // can navigate back
        transaction.replace(R.id.container, fragment);
        if (add_to_backstack) transaction.addToBackStack(null);

     if(oldt!=t)
     {  fragmentTransaction.setCustomAnimations(R.anim.slide_in, R.anim.slide_out);
     oldt=t;
     }
     else
     {
         fragmentTransaction.setCustomAnimations(R.anim.none, R.anim.none);
     }

        // Commit the transaction
        transaction.commit();