Android setError does not follow slide animation

I have the following page in my android app (I cannot take a screenshot to just draw it): I have edittexts and I am using the edittext property showError.

enter image description here

Then, at some point in the program, the entire page animates and slides down. The problem is that when the edittexts slides down, the error message does not slide, it holds its position and looks like this:

enter image description here

Here is my layout file for edittexts:

<RelativeLayout 
            android:layout_marginTop="10dp"
            android:id="@+id/loginFieldsPanel"
            android:layout_below="@+id/loginWarningPanel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="@drawable/login_edit_fields_bg">
            <RelativeLayout 
                android:id="@+id/userNamePanel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <RelativeLayout 
                    android:id="@+id/userNameWithBg"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/login_eposta_image_bg"/>
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/login_username_left_image"/>
                </RelativeLayout>

                <com.example.CustomEditText
                    android:paddingRight="5dp"
                    android:id="@+id/editUserName"
                    android:layout_toRightOf="@+id/userNameWithBg"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="5dp"
                    android:layout_centerVertical="true"
                    android:textSize="16sp"
                    custom:customFontType="regular"
                    android:hint="@string/login_identity_hint"
                    android:background="@null"/>
            </RelativeLayout>
            <ImageView 
                android:id="@+id/login_fields_line"
                android:layout_below="@+id/userNamePanel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/login_fileds_line"/>
            <RelativeLayout 
                android:layout_below="@+id/login_fields_line"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <RelativeLayout 
                    android:id="@+id/passwordWithBg"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/login_password_image_bg"/>
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/login_password_left_image"/>
                </RelativeLayou
                <com.example.CustomEditText
                    android:layout_margin="5dp"
                    android:paddingRight="5dp"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@+id/passwordWithBg"
                    android:id="@+id/editPassword"
                    android:background="@null"
                    android:inputType="textPassword"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textSize="16sp"
                    custom:customFontType="regular"
                    android:hint="@string/login_password_hint"/>
            </RelativeLayout>

        </RelativeLayout>

      

And this is how I perform the animation:

ObjectAnimator.ofFloat(basePanel, "translationY", start, finish).setDuration(duration).start();

      

where basePanel is the root of my layout file.

So, can anyone help me fix this?

thank

+3


source to share


1 answer


  • An easy way to add an external attribute is android:animateLayoutChanges="true"

    .
  • Here are two ways to start slideshow and slide down.

    public TranslateAnimation getShow()
    {
        TranslateAnimation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
        mShowAction.setDuration(500);
        return mShowAction;
    }
    
    public TranslateAnimation getHide()
    {
        TranslateAnimation mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF,   
                0.0f, Animation.RELATIVE_TO_SELF, 0.0f,   
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,   
                -1.0f);  
        mHiddenAction.setDuration(500); 
        return mHiddenAction;
    }
    
          

    How to use it:

    view.startAnimation(getShow());
    
          



0


source







All Articles