I added animation during transitions between activites ... It’s just that one activates something like another ...
But I have activations that use FrameLayout and depending on what I need, I make this or that FrameLayout visible and the other I hide ...
but it looks not so beautiful ...
Is there any way to add animation when changing FrameLayout ?
I have 2 frames
here in this markup
<LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="60" android:orientation="horizontal"> <FrameLayout android:id="@+id/registrationFrame" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:gravity="center|top" android:orientation="vertical"> <com.example.android.camera2basic.tools.fontView.ExButton style="@style/ExButton" android:layout_marginBottom="25dp" android:layout_marginTop="5dp" android:background="@drawable/stylelogbutton" android:onClick="RegMe" android:text="@string/registration_by_mail" android:textColor="@color/color_white" /> <com.example.android.camera2basic.tools.fontView.ExTextView style="@style/ExTextViewStyle" android:layout_width="200dp" android:layout_height="wrap_content" android:gravity="start" android:text="@string/agree" android:textColor="@color/color_white" android:textSize="15dp" /> </LinearLayout> <com.example.android.camera2basic.tools.fontView.ExTextView android:id="@+id/tvAutAct3" style="@style/ExTextViewStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:onClick="goToLogIn" android:text="@string/i_am_already_user" android:textColor="@color/color_white" /> </RelativeLayout> </FrameLayout> <FrameLayout android:id="@+id/loginFrame" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical"> <com.example.android.camera2basic.tools.fontView.ExTextView android:id="@+id/tvLogAct3" style="@style/ExTextViewStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/log_in_by_e_mail" android:textColor="@color/color_white" /> <android.support.design.widget.TextInputLayout android:id="@+id/tilEmailLog" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="16dp" android:layout_marginStart="16dp"> <com.example.android.camera2basic.tools.fontView.ExEditText android:id="@+id/etEmailLog" style="@style/ExTextViewStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="start" android:hint="@string/email" android:inputType="textEmailAddress" android:textColor="@color/color_white" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:id="@+id/tilPasswordLog" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="16dp" android:layout_marginStart="16dp"> <com.example.android.camera2basic.tools.fontView.ExEditText android:id="@+id/etPasswordLog" style="@style/ExTextViewStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="start" android:hint="@string/password" android:inputType="textPassword" android:textColor="@color/color_white" /> </android.support.design.widget.TextInputLayout> <com.example.android.camera2basic.tools.fontView.ExButton android:id="@+id/bLogIn" style="@style/ExButton" android:layout_marginBottom="5dp" android:layout_marginTop="15dp" android:background="@drawable/stylelogbutton" android:onClick="userLogIn" android:text="@string/log_in" android:textStyle="bold" /> <com.example.android.camera2basic.tools.fontView.ExTextView style="@style/ExTextViewStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:onClick="forgotPassword" android:text="@string/forgot_your_password" android:textColor="@color/color_white" /> </LinearLayout> </FrameLayout> </LinearLayout> I have a button when I click on which frames change. Like this
registrationFrame.animate().alpha(0).start(); loginFrame.animate().alpha(1).start(); But the problem is that when I install registrationFrame alpha(0) , it disappears beautifully, but nothing appears behind it ... The code does not react at all to the fact that loginFrame set to alpha(1) ...
I did it differently, I put only the function on one button
registrationFrame.animate().alpha(0).start(); And on another button set the function
loginFrame.animate().alpha(1).start(); I press on the first everything disappears, I press on the second nothing appears. ((
Then I tried the same function to put the same loginFrame loginFrame on these 2 buttons, only in the first case the function sets alpha(0) and in the second alpha(1) ...
Everything works for this frame, it disappears beautifully, then it appears.
But why does this work only for the same frame? Why is it impossible to make one disappear and the other appear?
setVisibility(View.GONE), then first make it visible, and then animate the alpha, not forgetting before the animated transition to alpha 1f, first set the alpha to 0f - xkorf... Does it automatically convert ...? - Aleksey TimoshchenkostartAnimation(animation)method) or do what you say? I mean that in your case we assign the alpha directly to the view element, and if we use the animation with the parameters specified through the file, will the final values be assigned to the view element? That said it)) Not sure that you understood my point ... - Aleksey Timoshchenko