I am new to Android animation, and my requirement is to translate a view from one layout to a layout in one XML file when this view is clicked.
Scenario: Suppose I click on the button present at the top of the header in the XML file and it should move / translate down (it should influence the fact that it lies on another layout down to the header), and I also want the user clicks on the same again, now he must go to the starting position.
Here I explain with my xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/app_bg" android:orientation="vertical" > <RelativeLayout android:id="@+id/top" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/header" android:paddingLeft="10dp" android:paddingRight="10dp" > <Button android:id="@+id/btnSearchHeader" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_centerInParent="true" android:background="@drawable/search_icon" /> </RelativeLayout> <RelativeLayout android:id="@+id/bottom" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/app_transparent" android:paddingLeft="10dp" android:paddingRight="10dp" android:layout_marginTop="10dp" android:visibility="visible" > <Button android:id="@+id/btnMenu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_marginRight="5dp" android:text="ABC" /> <Button android:id="@+id/btnSearchSelected" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@+id/btnMenu" android:text="CDE" /> </RelativeLayout> </LinearLayout>
MORE EXACT REQUIREMENTS REQUIREMENTS (please read carefully :)
Here I have two internal internal layouts: -
Top layout - id-> top Bottom Layout-id β bottom
Now the view (Button β btnSearchHeader) lies in my top layout, and I want to animate the same with the bottom layout (this should affect the fact that it is translated using the translation animation to the bottom layout) when this button is clicked, and when the user clicks to this button, it should again return to its original position using translational animation .. that is, it should be displayed in the top layout
I donβt know how to convey these effects using the translation of animations, but I just have a basic knowledge of translation animation, which is not enough for me to work on my requirement.
Noticeable noticeable help of any type.
thanks
android android-layout translate-animation
samsad
source share