0

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

0

2 Answers 2

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);
Sign up to request clarification or add additional context in comments.

2 Comments

is this only for buttons or for the whole activity .. but here in this code where th button item is specified ??
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.stackoverflow.com/questions/3389501/…
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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.