Android爆炸转换就像幻灯片转换一样

时间:2017-01-12 18:41:11

标签: android-transitions

我正在使用带有爆炸转换的beginTransitionDelayed。问题是所有视图都从1个方向滑入而不是从不同角度进入。

new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
        final RelativeLayout rootView = (RelativeLayout) findViewById(R.id.createOfferSummary_rootView);
        final Explode explode = new Explode();
        explode.setDuration(1000)
               .setInterpolator(new AccelerateDecelerateInterpolator());
        TransitionManager.beginDelayedTransition(rootView, explode);
        rootView.setVisibility(View.VISIBLE);
    }
}, 500);

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/createOfferSummary_rootView"
    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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:visibility="invisible"
    tools:context="com.activities.CreateOfferSummaryActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="Contacts Selected:"
        android:textAppearance="?android:attr/textAppearanceMedium"/>

    <LinearLayout

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:transitionGroup="true">


        <TextView
            android:id="@+id/createOfferSummary_timeFrame"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Time Frame:"
            android:textAppearance="?android:attr/textAppearanceMedium"/>

        <TextView
            android:id="@+id/createOfferSummary_location"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:text="Location"
            android:textAppearance="?android:attr/textAppearanceMedium"/>

    </LinearLayout>
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

TL; DR尝试将转换的开始延迟设置为零

我遇到了这个问题,因为我在爆炸过渡上设置了延迟,看起来爆炸过渡的传播没有延迟,甚至在过渡开始之前就完成了。没有传播,爆炸过渡看起来就像幻灯片。