Android: MotionLayout не может отключить видимость вида, вид остается видимым - PullRequest
0 голосов
/ 07 мая 2020

У меня есть макет, который является MotionLayout, он должен быть FrameLayouts, для которого я определил начало и конец ConstraintSets motionscene. И они правильно анимированы.

Затем под этим анимированным FrameLayout я добавил 2 TextView и при щелчке я пытаюсь скрыть один и показать другой, но тогда оба остаются видимыми

 <!-- No Account Line -->
    <TextView
        android:id="@+id/noAccountTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text="@string/no_account_question"
        android:fontFamily="@font/avenirnext_demibold"
        android:textSize="15sp"
        android:textColor="@color/black"

        tools:ignore="MissingConstraints" />

<TextView
    android:id="@+id/signupTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@string/signup_answer"
    android:fontFamily="@font/avenirnext_demibold"
    android:textSize="15sp"
    android:textColor="@color/colorAccent"

    android:selectAllOnFocus="false"
    android:linksClickable="false"
    android:autoLink="all"

    android:clickable="true"

    tools:ignore="MissingConstraints" />

<TextView
    android:id="@+id/nowTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@string/now_answer"
    android:fontFamily="@font/avenirnext_demibold"
    android:textSize="15sp"
    android:textColor="@color/black"

    tools:ignore="MissingConstraints" />


<androidx.constraintlayout.helper.widget.Flow
    android:id="@+id/noAccountLine"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    app:flow_horizontalGap="8dp"

    app:constraint_referenced_ids="noAccountTextView, signupTextView, nowTextView"
    app:layout_constraintVertical_bias="1.0"

    android:layout_marginBottom="16dp"
    android:visibility="visible"

    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    />

<!-- No Account Line -->

<!-- Have Account Line -->

<TextView
    android:id="@+id/haveAccountTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@string/have_account_question"
    android:fontFamily="@font/avenirnext_demibold"
    android:textSize="15sp"
    android:textColor="@color/black"

    tools:ignore="MissingConstraints" />

<TextView
    android:id="@+id/loginTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@string/log_in_answer"
    android:fontFamily="@font/avenirnext_demibold"
    android:textSize="15sp"
    android:textColor="@color/colorAccent"

    android:selectAllOnFocus="false"
    android:linksClickable="false"
    android:autoLink="all"

    android:clickable="true"

    tools:ignore="MissingConstraints" />

<TextView
    android:id="@+id/insteadTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@string/instead_answer"
    android:fontFamily="@font/avenirnext_demibold"
    android:textSize="15sp"
    android:textColor="@color/black"

    tools:ignore="MissingConstraints" />

<androidx.constraintlayout.helper.widget.Flow
    android:id="@+id/haveAccountLine"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    app:flow_horizontalGap="8dp"

    app:constraint_referenced_ids="haveAccountTextView, loginTextView, insteadTextView"
    app:layout_constraintVertical_bias="1.0"

    android:layout_marginBottom="16dp"
    android:visibility="gone"

    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    />

Могу я сделать это в MotionLayout или Мне нужно обернуть FrameLayout в отдельный MotionLayout и поместить его в ConstraintLayout с этим TextView. Кажется, что начальное / конечное состояние, в котором я не определил поведение для этого TextViews (ограничений), что-то портит.

Я пробовал использовать что-то вроде этого

переопределить удовольствие onViewCreated (view: View, savedInstanceState: Bundle?) {Super.onViewCreated (view, savedInstanceState)

    signupTextView.setOnClickListener {
        //authenticationFragment.transitionToEnd()
        //isFrontCard = false

        /*
        val transition: Transition = Fade()
        transition.setDuration(350)
        transition.addTarget(R.id.noAccountLine)
        transition.addTarget(R.id.haveAccountLine)

        TransitionManager.beginDelayedTransition(authenticationFragment, transition)
        */

        noAccountLine.isGone = true
        haveAccountLine.isVisible = true
    }

Также после комментирования кода не работает. Могу ли я сделать некоторые просмотры, пропущенные MotionLayout? Или мне нужно добавить еще одну вложение раскладок?

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