J'ai une transition de scène et je veux utiliser l'animation Recolor pour changer l'arrière-plan d'un ViewGroup de transparent à une autre couleur. Voici mon login_to_register.xml
:La transition de Recolor ne fonctionne-t-elle pas pour VIewGroup?
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<fade android:fadingMode="fade_out"/>
<fade android:fadingMode="fade_in">
<targets>
<target android:targetId="@id/passwordEditor" />
<target android:targetId="@id/loginNameEditor" />
</targets>
</fade>
<!--<changeTransform />-->
<changeBounds />
<recolor>
<targets>
<target android:targetId="@id/loginOptions" />
</targets>
</recolor>
</transitionSet>
C'est le XML pour la mise en page du fragment, qui est à l'intérieur du ViewPager.
<FrameLayout
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent" android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/onboarding_bg"
/>
<LinearLayout
android:id="@+id/loginOptions"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:background="@android:color/transparent"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
>
<android.support.design.widget.TextInputLayout
android:id="@+id/loginNameEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email"
app:errorEnabled="true"
app:hintTextAppearance="@style/BlackFloatingTextTextAppearance"
android:visibility="gone"
tools:visibility="visible"
>
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@={regModel.emailAddress, default=`twinkle`}"
android:inputType="textEmailAddress"
android:maxLength="254"
android:onFocusChange="@{(v, focus) -> context.loginFocusChanged(true, focus)}"
android:afterTextChanged="@{() -> context.loginTextChanged()}"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/passwordEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
app:passwordToggleEnabled="true"
app:errorEnabled="true"
app:hintTextAppearance="@style/BlackFloatingTextTextAppearance"
app:counterEnabled="true"
app:counterMaxLength="50"
android:visibility="gone"
tools:visibility="visible"
>
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@={regModel.password}"
android:inputType="textPassword"
android:fontFamily="monospace"
android:onFocusChange="@{(v, focus) -> context.loginFocusChanged(false, focus)}"
android:afterTextChanged="@{() -> context.loginTextChanged()}"
/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:textAppearance="@style/TextAppearance.Design.Error"
android:gravity="start"
android:visibility="gone"
tools:visibility="visible"
/>
<!--<Button-->
<!--android:id="emailAuthButton"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginTop="@dimen/loginButtonSpacing"-->
<!--android:text="@string/login"-->
<!--style="@style/PrimaryColorButtonBorderlessStyle"-->
<!--android:onClick="loginEmail"-->
<!--/>-->
<com.google.android.gms.common.SignInButton
android:id="@+id/googButton"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/loginButtonSpacing"
android:layout_marginTop="@dimen/loginButtonSpacing"
android:onClick="loginGoogle"
app:buttonSize="wide"
/>
<com.facebook.login.widget.LoginButton
android:id="@+id/fbButton"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/loginButtonSpacing"
app:com_facebook_login_text="@string/com_facebook_loginview_log_in_button"
android:layout_marginBottom="@dimen/loginButtonSpacing"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:onClick="loginFB"
/>
<TextView
android:id="@+id/emailInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_marginTop="@dimen/register_row_spacing"
android:layout_marginStart="10dp"
android:text="@string/unauth_email_prompt"
android:textColor="?android:attr/textColorPrimaryInverse"
/>
<Button
android:id="@+id/unfederatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/loginButtonSpacing"
android:layout_marginBottom="@dimen/loginButtonSpacing"
android:text="@string/create_account"
style="@style/ScalableBorderlessButton"
android:textColor="@color/colorAccent"
android:minHeight="53dp"
android:onClick="showUnfederatedUI"
/>
<TextView
android:id="@+id/forgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginTop="15dp"
android:paddingTop="@dimen/smallLinkTopPadding"
android:paddingBottom="@dimen/smallLinkBottomPadding"
android:paddingLeft="@dimen/smallLinkHPadding"
android:paddingRight="@dimen/smallLinkHPadding"
app:hypertext="@{R.string.forgot_pass}"
android:background="?android:attr/selectableItemBackground"
tools:text="@string/forgot_pass"
android:textSize="@dimen/smallLinkTextSize"
android:onClick="recoverPassword"
android:visibility="gone"
/>
</LinearLayout>
</FrameLayout>
Maintenant, le point de vue que je veux utiliser Redéfinir est l'id loginOptions
. Vous pouvez voir que je donne son targetId spécifique dans la transition. Et il est transparent
par défaut en cas de problèmes à partir de null. Donc, est ici le code pour commencer la transition de la scène
val trans = TransitionInflater.from(this).inflateTransition(R.transition.login_to_register)
TransitionManager.beginDelayedTransition(this.dataBinding.root, trans)
this.loginBinding!!.loginNameEditor.visibility = View.VISIBLE
this.loginBinding!!.passwordEditor.visibility = View.VISIBLE
this.loginBinding!!.error.visibility = View.VISIBLE
this.loginBinding!!.googButton.visibility = View.GONE
this.loginBinding!!.fbButton.visibility = View.GONE
this.loginBinding!!.emailInfo.visibility = View.GONE
this.loginBinding!!.forgotPassword.visibility = View.VISIBLE
val color = this.resources.getColor(R.color.almostWhite)
this.loginBinding!!.loginOptions.background = ColorDrawable(color)
Je ne suis pas la mise en page d'y compris l'activité du ViewPager, il est simple et n'a probablement pas de problème, parce que toutes les autres transitions fonctionnent! Oui, tous les changements de VISIBILITY fonctionnent correctement, et les limites changent. Quel est le problème avec le Recolor? Edit: Laissez-moi ajouter que, si je supprime <recolor>
, l'arrière-plan de @id/loginOptions
ne changer à almostWhite
.
Je pense que la lecture de la structure Recolor est inexacte: il y a une vérification pour 2 ColorDrawables. Il y a une explication de pourquoi cela ne fonctionne pas sur le lien de problème dans ma réponse. – user3175580