i have a button at the bottom of layout, on clicking on that button that button should be moved to top(with 48 DP margin from top). How to do that please help.
Asked
Active
Viewed 483 times
0
-
1Refer this link http://stackoverflow.com/questions/20323628/android-layout-animations-from-bottom-to-top-and-top-to-bottom-on-imageview-clic – sasikumar Jun 15 '15 at 11:50
-
this is not working, i tried it before. – user1478068 Jun 15 '15 at 11:55
1 Answers
0
place this move.xml in anim folder
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromYDelta="0%p"
android:toYDelta="-80%p"
android:duration="800" />
</set>
and use for animate that button use this code
// Animation
final Animation move_anim = AnimationUtils.loadAnimation(this,R.anim.move);
and put this in to your onclick event
btn.startAnimation(move_anim)

Kishan Soni
- 816
- 1
- 6
- 19
-
-
no need of margin set in this animation .xml you can keep margin as it is from your main .xml if still you cant get it just feel free to ask.. :) – Kishan Soni Jun 15 '15 at 13:08