I have my Android app with a login activity . when the user gets logged in i need another activity which contains four image buttons and the main need is that when the activity comes up the buttons must slide to the middle from the right side . Can anyone help me with the codes
Asked
Active
Viewed 657 times
2 Answers
1
Step 1.make anim folder and create xml with name slide_right.xml and put the below content
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="500" />
Step 2.Into the onCreate() method of your MainActivity class, load animation and set it to your view buttons
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_right);
yourbutton.startAnimation(animation);

rafi
- 364
- 3
- 9
-
is this only for buttons or for the whole activity .. but here in this code where th button item is specified ?? – user3708226 Dec 12 '14 at 09:39
-
yes this for the button which you have specified to be loaded from right side of the screen.First find the id of the buttons and setAnimation to that as i have specified yourbuttonid.startAnimation(animation). you can override the screen transitions.http://stackoverflow.com/questions/3389501/activity-transition-in-android – rafi Dec 12 '14 at 09:52
0
You can also use View Flipper
<ViewFlipper
android:id="@+id/myFlipper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateFirstView="true"
android:autoStart="true"
android:flipInterval="500"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/myImage" />
</ViewFlipper>

Aamir Shahzad
- 61
- 3