我面临着Transitions支持版本的一个奇怪问题。
我有3个RadioGroups,每个有两个孩子,我需要依次让它们中的一个消失,并在同一个位置出现另一个。可见性更改适用于drawable,但文本和RadioButton不会消失。
我在CardView中有这段代码
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="0dp"
android:layout_height="0dp"
card_view:layout_constraintStart_toEndOf="@id/card_view1"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintTop_toTopOf="parent"
card_view:layout_constraintBottom_toBottomOf="parent"
android:layout_margin="10dp"
android:id="@+id/card_view2"
android:layout_gravity="center"
android:background="#FFF"
card_view:cardCornerRadius="7dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/containerCardview"
android:padding="5dp">
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintTop_toTopOf="parent"
card_view:layout_constraintBottom_toTopOf="@+id/RadioGroup1"
android:id="@+id/TextViewPago"
android:gravity="center"
android:text="@string/pref_login" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/RadioGroupTipo"
android:visibility="invisible"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/TextViewPago"
card_view:layout_constraintBottom_toTopOf="@+id/RadioGroup2"
android:orientation="horizontal">
<RadioButton
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:id="@+id/ProfesionalUser"
android:text="@string/ProfesionalUser"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_medico"/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:id="@+id/FamiliarUser"
android:text="@string/FamiliarUser"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_familia"/>
</RadioGroup>
<RadioGroup
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/RadioGroup1"
android:visibility="invisible"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/TextViewPago"
card_view:layout_constraintBottom_toTopOf="@+id/RadioGroup2"
android:orientation="horizontal">
<RadioButton
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:id="@+id/YoungUser"
android:text="@string/YoungUser"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_hermano"/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:id="@+id/OldUser"
android:text="@string/OldUser"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_abuelo"/>
</RadioGroup>
<RadioGroup
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/RadioGroup1"
card_view:layout_constraintBottom_toTopOf="@id/sign_in_button"
android:id="@+id/RadioGroup2"
android:orientation="horizontal">
<RadioButton
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:id="@+id/MaleUser"
android:text="@string/MaleUser"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/nino"/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:id="@+id/FemaleUser"
android:text="@string/FemaleUser"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/nina"/>
</RadioGroup>
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="0dp"
android:layout_height="0dp"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintTop_toBottomOf="@id/RadioGroup2"
card_view:layout_constraintBottom_toBottomOf="parent"
/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintTop_toBottomOf="@id/RadioGroup2"
card_view:layout_constraintBottom_toBottomOf="parent"
android:visibility="invisible"
android:id="@+id/BotonContacto"
android:text="@string/cont_ctanos"/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
这就是我用来切换visibilty的代码就是这个
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch (radioGroup.getCheckedRadioButtonId()) {
case R.id.ProfesionalUser:
SingIn.setEnabled(true);
break;
case R.id.FamiliarUser:
//Animaciones
android.support.transition.Transition fade = new Fade(Fade.OUT);
TransitionManager.beginDelayedTransition(RadioGroupTipo,fade);
RadioGroupTipo.setVisibility(View.INVISIBLE);
RadioGroupTipo.requestLayout();
android.support.transition.Transition fadeEdad = new Fade(Fade.IN);
TransitionManager.beginDelayedTransition(RadioGroupEdad,fadeEdad);
RadioGroupEdad.setVisibility(View.VISIBLE);
RadioGroupEdad.requestLayout();
break;
case R.id.MaleUser:
SingIn.setEnabled(true);
break;
case R.id.FemaleUser:
SingIn.setEnabled(true);
break;
case R.id.YoungUser:
android.support.transition.Transition fadeSexo = new Fade(Fade.IN);
TransitionManager.beginDelayedTransition(RadioGroupSexo,fadeSexo);
RadioGroupSexo.setVisibility(View.VISIBLE);
RadioGroupSexo.requestLayout();
break;
case R.id.OldUser:
android.support.transition.Transition fadeSexo1 = new Fade(Fade.IN);
TransitionManager.beginDelayedTransition(RadioGroupSexo,fadeSexo1);
RadioGroupSexo.setVisibility(View.VISIBLE);
RadioGroupSexo.requestLayout();
break;
}
}
我已尝试过requestLayout和许多其他奇怪的解决方法。
任何帮助?
这里是一张如何看待最后的图片 (抱歉Imgur今天真的很慢) http://es.tinypic.com/r/2cz36nr/9
由于