Android ChangeBounds过渡

时间:2018-08-15 12:52:55

标签: java android transition

我正在尝试在两个视图之间进行过渡(扩展/收缩)。我使用了以下代码:

ViewOne.xml

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
    android:layout_width="match_parent"
    android:layout_height="330dp"
    android:background="@color/white"/>
</RelativeLayout>

ViewTwo.xml

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_edit_search"
android:layout_marginEnd="70dp">

<EditText
    android:id="@+id/et_search"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:hint="@string/edit_search_hint"
    android:textColor="@color/grey"
    android:textColorHint="@color/grey"
    android:textSize="16sp"
    android:imeOptions="actionSearch"
    android:inputType="textAutoCorrect"
    android:paddingStart="50dp"
    android:paddingEnd="50dp"/>

<TextView
    android:id="@+id/tv_search"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:textSize="20sp"
    android:text="@string/ic_search"
    android:textColor="@color/purple"
    android:gravity="center"/>
</RelativeLayout>

TestFragment.java

RelativeLayout parent = rootView.findViewById(R.id.rl_parent);
parent.addView(viewTwo);
Scene expandScene = new Scene(parent, viewOne);
Scene shrinkScene = new Scene(parent, viewTwo);

TransitionManager.go(expandScene, new ChangeBounds());

问题在于过渡未显示为平滑过渡,而是viewOne布局仅显示为无过渡(就像它直接添加到父级一样)。

为什么不执行转换?

0 个答案:

没有答案