ConstraintSet Анимировать слайд в ImageViews - PullRequest
0 голосов
/ 10 июня 2018

Новое в ConstraintSet.Попытка анимировать два ImageViews на заставке.Я хочу, чтобы prefix_text скользил вправо от левого поля, а суффикс_text скользил влево от правого поля.Но ничего не происходит.Я не вижу, что мне не хватает.

class SplashActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_splash_start)
        addAnimationOperations()
    }

    private fun addAnimationOperations() {

        val constraint1 = ConstraintSet()
        constraint1.clone(root)
        val constraint2 = ConstraintSet()
        constraint2.clone(this, R.layout.activity_splash_done)

        TransitionManager.beginDelayedTransition(root)
        constraint2.applyTo(root)
    }
}

activity_splash_start.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#333">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/frameLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">


        <ImageView
            android:id="@+id/runners"
            android:layout_width="200dp"
            android:layout_height="0dp"
            android:layout_marginTop="8dp"
            android:contentDescription="@string/whatever"
            app:layout_constraintDimensionRatio="1024:940"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/logo_runners" />

        <android.support.constraint.ConstraintLayout
            android:id="@+id/text_container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/runners">

            <ImageView
                android:id="@+id/prefix_text"
                android:layout_width="0dp"
                android:layout_height="30dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintDimensionRatio="672:215"
                app:layout_constraintEnd_toStartOf="parent"
                app:srcCompat="@drawable/logo_name" />

            <ImageView
                android:id="@+id/suffix_text"
                android:layout_width="0dp"
                android:layout_height="30dp"
                app:layout_constraintDimensionRatio="352:215"
                app:layout_constraintStart_toEndOf="parent"
                app:srcCompat="@drawable/logo_dot_club" />
        </android.support.constraint.ConstraintLayout>

    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>

activity_splash_done.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#333">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/frameLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">


        <ImageView
            android:id="@+id/runners"
            android:layout_width="200dp"
            android:layout_height="0dp"
            android:layout_marginTop="8dp"
            android:contentDescription="@string/whatever"
            app:layout_constraintDimensionRatio="1024:940"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/logo_runners" />

        <android.support.constraint.ConstraintLayout
            android:id="@+id/text_container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/runners">

            <ImageView
                android:id="@+id/prefix_text"
                android:layout_width="0dp"
                android:layout_height="30dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintDimensionRatio="672:215"
                app:layout_constraintStart_toStartOf="parent"
                app:srcCompat="@drawable/logo_name" />

            <ImageView
                android:id="@+id/suffix_text"
                android:layout_width="0dp"
                android:layout_height="30dp"
                app:layout_constraintDimensionRatio="352:215"
                app:layout_constraintStart_toEndOf="@+id/werun_text"
                app:srcCompat="@drawable/logo_dot_club" />
        </android.support.constraint.ConstraintLayout>

    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...