gpt4 book ai didi

android - 无法更改 MotionLayout 中 TextInputLayout 的可见性

转载 作者:行者123 更新时间:2023-12-04 01:45:10 29 4
gpt4 key购买 nike

我正在尝试 MotionLayout第一次,我在更改 TextInputLayouts 的可见性时遇到问题在我的MotionScene .

motion_scene.xml

<?xml version="1.0" encoding="utf-8"?>
<MotionScene
xmlns:motion="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<Transition
motion:constraintSetStart="@id/afinstall"
motion:constraintSetEnd="@id/signin"
motion:duration="1000">

<OnClick
motion:targetId="@id/button_sign_in"
motion:clickAction="transitionToEnd"/>

<OnClick

/>

</Transition>

<Transition
motion:constraintSetEnd="@id/afinstall"
motion:constraintSetStart="@id/signin"
motion:duration="1000">

<OnClick
motion:targetId="@id/button_back"
motion:clickAction="transitionToEnd"/>

<OnClick

/>

</Transition>

.............

<ConstraintSet android:id="@+id/afinstall">

....

<Constraint
android:layout_width="282dp"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginEnd="8dp"
motion:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="8dp"
motion:layout_constraintStart_toStartOf="parent" android:id="@+id/sign_in_username_tf"
android:layout_marginTop="1dp" motion:layout_constraintTop_toBottomOf="@+id/app_slogan"
android:visibility="gone" />
<Constraint
android:layout_width="282dp"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginStart="8dp"
motion:layout_constraintStart_toStartOf="parent" android:layout_marginEnd="8dp"
motion:layout_constraintEnd_toEndOf="parent" android:id="@+id/sign_in_password_tf"
android:layout_marginTop="1dp" motion:layout_constraintTop_toBottomOf="@+id/sign_in_username_tf"
android:visibility="gone"/>

....
</ConstraintSet>

<ConstraintSet android:id="@+id/signin">

....

<Constraint
android:layout_width="282dp"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginEnd="8dp"
motion:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="8dp"
motion:layout_constraintStart_toStartOf="parent" android:id="@+id/sign_in_username_tf"
android:layout_marginTop="110dp" motion:layout_constraintTop_toBottomOf="@+id/app_slogan"
android:visibility="visible"/>
<Constraint
android:layout_width="282dp"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginTop="15dp"
motion:layout_constraintTop_toBottomOf="@+id/sign_in_username_tf" android:layout_marginStart="8dp"
motion:layout_constraintStart_toStartOf="parent" android:layout_marginEnd="8dp"
motion:layout_constraintEnd_toEndOf="parent" android:id="@+id/sign_in_password_tf"
android:visibility="visible"/>

....

</ConstraintSet>

</MotionScene>


activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/motion_scene"
tools:context=".MainActivity">

....

<android.support.design.widget.TextInputLayout
android:layout_width="282dp"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="parent" android:id="@+id/sign_in_username_tf"
android:layout_marginTop="1dp" app:layout_constraintTop_toBottomOf="@+id/app_slogan"
android:visibility="gone">

<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/nunito_sans" android:textSize="20sp"
android:textColor="@color/colorPrimaryLi"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="282dp"
android:layout_height="wrap_content"
android:hint="Password" app:hintEnabled="true"
app:hintAnimationEnabled="true"
android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent" android:id="@+id/sign_in_password_tf"
android:layout_marginTop="1dp" app:layout_constraintTop_toBottomOf="@+id/sign_in_username_tf"
android:visibility="gone">

<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/nunito_sans" android:textSize="20sp"
android:textColor="@color/colorPrimaryLi"/>
</android.support.design.widget.TextInputLayout>

....

</android.support.constraint.motion.MotionLayout>

我试过摆弄东西,但我无法指出它为什么会发生。

请不要将此标记为重复,因为这是我正在尝试的一个相当新的库。如果需要,我很乐意进一步详细说明。

最佳答案

我发现当前(alpha 5)可见性 cange 不起作用(如果您将其设置在约束集中它会起作用,但不适用于事件或关键帧集)
作为一种解决方法,我使用 alpha 0-1 使 View 可见或不可见,并添加 incode 监听器以使其可点击

关于android - 无法更改 MotionLayout 中 TextInputLayout 的可见性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55561575/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com