我想使用Contarint集更改视图可见性,创建两个相同的视图,但是在第二个视图中使视图可见性消失,实际上,当我运行活动时,它仅显示视图可见性已经消失的第二个XML,但是没有动画,它的可见性如何。
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<LinearLayout
android:id="@+id/socialPart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/appName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_bold"
android:gravity="center"
android:text="@string/app_name_title"
android:textColor="@color/blue"
android:textSize="40sp" />
<LinearLayout
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="20dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_arrow_left" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_bold"
android:gravity="center"
android:text="@string/create_account"
android:textColor="@color/title_color"
android:textSize="25sp" />
</LinearLayout>
<Button
android:id="@+id/facebook"
style="@style/button_main"
android:layout_marginTop="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_facebook"
android:drawablePadding="20dp"
android:gravity="start|center_vertical"
android:paddingStart="20dp"
android:paddingEnd="0dp"
android:text="@string/continue_facebook"
android:textColor="@color/gray"
android:textSize="20sp" />
<Button
android:id="@+id/google"
style="@style/button_main"
android:layout_marginTop="15dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_google"
android:drawablePadding="20dp"
android:gravity="start|center_vertical"
android:paddingStart="20dp"
android:paddingEnd="0dp"
android:text="@string/continue_google"
android:textColor="@color/gray"
android:textSize="20sp" />
<LinearLayout
android:id="@+id/useEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<View
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_weight="0.3"
android:background="#DADADA" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_weight="0.4"
android:fontFamily="@font/poppins_medium"
android:gravity="center"
android:text="@string/use_register_email" />
<View
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_weight="0.3"
android:background="#DADADA" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="@dimen/main_button_size"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_mail"
android:drawablePadding="10dp"
android:hint="@string/hint_email"
android:paddingStart="20dp"
android:paddingEnd="0dp"
app:layout_constraintTop_toBottomOf="@id/socialPart" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="@dimen/main_button_size"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_lock"
android:drawablePadding="10dp"
android:hint="@string/hint_password"
android:inputType="textPassword"
android:paddingStart="20dp"
android:paddingEnd="0dp"
app:layout_constraintTop_toBottomOf="@+id/email" />
<EditText
android:id="@+id/confirmPass"
android:layout_width="match_parent"
android:layout_height="@dimen/main_button_size"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_lock"
android:drawablePadding="10dp"
android:hint="@string/hint_confirm_pass"
android:inputType="textPassword"
android:paddingStart="20dp"
android:paddingEnd="0dp"
app:layout_constraintTop_toBottomOf="@+id/password" />
<TextView
android:id="@+id/termAndServices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:drawablePadding="10dp"
android:fontFamily="@font/poppins_medium"
android:text="@string/term_and_condition"
android:textColor="#4D4D4D"
app:layout_constraintTop_toBottomOf="@+id/confirmPass" />
<Button
android:id="@+id/login"
style="@style/button_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginBottom="30dp"
android:backgroundTint="@color/gray"
android:text="@string/get_started"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
我的主要布局(其中的socialPart可见)
androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<LinearLayout
android:id="@+id/socialPart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/appName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_bold"
android:gravity="center"
android:text="@string/app_name_title"
android:textColor="@color/blue"
android:textSize="40sp" />
<LinearLayout
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="20dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_arrow_left" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_bold"
android:gravity="center"
android:text="@string/create_account"
android:textColor="@color/title_color"
android:textSize="25sp" />
</LinearLayout>
<Button
android:id="@+id/facebook"
style="@style/button_main"
android:layout_marginTop="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_facebook"
android:drawablePadding="20dp"
android:gravity="start|center_vertical"
android:paddingStart="20dp"
android:paddingEnd="0dp"
android:text="@string/continue_facebook"
android:textColor="@color/gray"
android:textSize="20sp" />
<Button
android:id="@+id/google"
style="@style/button_main"
android:layout_marginTop="15dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_google"
android:drawablePadding="20dp"
android:gravity="start|center_vertical"
android:paddingStart="20dp"
android:paddingEnd="0dp"
android:text="@string/continue_google"
android:textColor="@color/gray"
android:textSize="20sp" />
<LinearLayout
android:id="@+id/useEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<View
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_weight="0.3"
android:background="#DADADA" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_weight="0.4"
android:fontFamily="@font/poppins_medium"
android:gravity="center"
android:text="@string/use_register_email" />
<View
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_weight="0.3"
android:background="#DADADA" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="@dimen/main_button_size"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_mail"
android:drawablePadding="10dp"
android:hint="@string/hint_email"
android:paddingStart="20dp"
android:paddingEnd="0dp"
app:layout_constraintTop_toBottomOf="@id/socialPart" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="@dimen/main_button_size"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_lock"
android:drawablePadding="10dp"
android:hint="@string/hint_password"
android:inputType="textPassword"
android:paddingStart="20dp"
android:paddingEnd="0dp"
app:layout_constraintTop_toBottomOf="@+id/email" />
<EditText
android:id="@+id/confirmPass"
android:layout_width="match_parent"
android:layout_height="@dimen/main_button_size"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:background="@drawable/strock_rounded_button"
android:drawableStart="@drawable/ic_lock"
android:drawablePadding="10dp"
android:hint="@string/hint_confirm_pass"
android:inputType="textPassword"
android:paddingStart="20dp"
android:paddingEnd="0dp"
app:layout_constraintTop_toBottomOf="@+id/password" />
<TextView
android:id="@+id/termAndServices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:drawablePadding="10dp"
android:fontFamily="@font/poppins_medium"
android:text="@string/term_and_condition"
android:textColor="#4D4D4D"
app:layout_constraintTop_toBottomOf="@+id/confirmPass" />
<Button
android:id="@+id/login"
style="@style/button_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginBottom="30dp"
android:backgroundTint="@color/gray"
android:text="@string/get_started"
app:layout_constraintBottom_toBottomOf="parent" />
最后我想要拥有什么,但是当我运行我的应用程序时,它显示了第二个视图,其中可见性已经消失并且没有任何动画