android: How to give animation to view or edittext as like below image?

时间:2016-09-01 06:17:13

标签: android animation

Hello friends i need to some animation for EditText views, Here i given one image that in app start time two EditText. That in second EditText is below first EditText. When i click on second EditText that time EditText pop out and set below first EditText. I dont know how to done this. please help me. See below image. Thank you :)

enter image description here

XML CODE

   <LinearLayout
        android:id="@+id/llMylocationDestinationCustomer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/llHeaderView"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/ll1"
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_50"
            android:layout_below="@+id/llHeaderView"
            android:layout_margin="@dimen/margin_5">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent">

                <LinearLayout
                    android:id="@+id/llMyaddLayout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#D5AA30"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="18dp"
                        android:layout_height="18dp"
                        android:layout_gravity="center_vertical"
                        android:layout_margin="5dp"
                        android:src="@drawable/icn_location" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="top"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/margin_5"
                            android:text="Pickup"
                            android:textSize="@dimen/text_14"
                            android:textStyle="italic" />

                        <EditText
                            android:id="@+id/et_myLocation_Address"
                            android:layout_width="match_parent"
                            android:layout_height="25dp"
                            android:layout_marginBottom="@dimen/margin_5"
                            android:layout_marginLeft="5dp"
                            android:background="@android:color/transparent"
                            android:ellipsize="end"
                            android:enabled="true"
                            android:gravity="center_vertical"
                            android:hint="My Address"
                            android:maxLines="2"
                            android:paddingRight="30dp"
                            android:singleLine="true"
                            android:text=""
                            android:textColor="@color/colorFarInListBlack"
                            android:textSize="15sp"
                            android:textStyle="bold" />
                    </LinearLayout>
                </LinearLayout>

                <ListView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/llMyaddLayout"></ListView>
            </RelativeLayout>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearLayout3"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_alignLeft="@+id/ll1"
            android:layout_alignStart="@+id/ll1"
            android:layout_below="@+id/ll1"
            android:layout_marginLeft="@dimen/margin_5"
            android:layout_marginRight="@dimen/margin_5">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"

                android:background="#D5AA30"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="18dp"
                    android:layout_height="18dp"
                    android:layout_gravity="center_vertical"
                    android:layout_margin="5dp"
                    android:src="@drawable/icn_location" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="top"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin_5"
                        android:text="Destination"
                        android:textSize="@dimen/text_14"
                        android:textStyle="italic" />

                    <EditText
                        android:id="@+id/et_destLocation_Address"
                        android:layout_width="match_parent"
                        android:layout_height="25dp"
                        android:layout_marginLeft="5dp"
                        android:background="@android:color/transparent"
                        android:ellipsize="end"
                        android:gravity="center_vertical"
                        android:hint="Destination location"
                        android:imeOptions="actionDone"
                        android:maxLines="1"
                        android:paddingRight="30dp"
                        android:singleLine="true"
                        android:text=""
                        android:textColor="@color/colorFarInListBlack"
                        android:textSize="15sp"
                        android:textStyle="bold"></EditText>

                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

2 个答案:

答案 0 :(得分:0)

根据您的问题您想要在edittext1下面的edittext2移动动画:

你必须在editext 2 onClickListner

上的editext 2对象上应用动画

尝试使用此代码进行动画处理:

 editext2.animate().translationY(35);
            LinearLayout.LayoutParams linearlayoutparms= (LinearLayout.LayoutParams) edittext1.getLayoutParams();
            ed2.setLayoutParams(linearlayoutparms);

答案 1 :(得分:-1)

Please go through view animation, object animator etc in android. By usiing this you can animate a view in your desired way

https://developer.android.com/guide/topics/graphics/prop-animation.html#views