2

I want to start my activity from bottom to top just like the sliding effect, and i searched and even used all the possible codes but its not working so can anyone please help me out for this. I even used below code:

overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);

I have also using following xmls also:

slide-in-up.xml

<translate
    android:duration="5000"
    android:fromYDelta="100%p"
    android:toYDelta="0" />

<alpha
    android:duration="5000"
    android:fromAlpha="0.0"
    android:toAlpha="1.0" />

slide-out-up.xml

<translate
    android:duration="5000"
    android:fromYDelta="0"
    android:toYDelta="-100%p" />

<alpha
    android:duration="5000"
    android:fromAlpha="1.0"
    android:toAlpha="0.0" />

but then too its not working.

Hetal Patel
  • 127
  • 1
  • 2
  • 9
  • When you say it's not working, what is wrong ? Is there an error ? Maybe you need to do "getRessource().getAnimation(R.anim.slide_in_up)" – Tsunaze Mar 31 '14 at 12:23
  • @Tsunaze It's not giving me error but animation what i want that's not going to place.(slide activity from bottom to UP). – Hetal Patel Mar 31 '14 at 12:34

3 Answers3

0

You can try something like

Animation animMove;
animMove = AnimationUtils.loadAnimation(getApplicationContext(),
                R.anim.move);
        animMove.setAnimationListener(this);

where your move.xml is

<?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="50%p"
        android:toYDelta="0%p"
        android:duration="800" />
</set>

Here you have to change fromYDelta parameter as per your requirenment.

InnocentKiller
  • 5,234
  • 7
  • 36
  • 84
  • I have try this but could not found animMove.setAnimationListener(this); this is giveing me error. – Hetal Patel Mar 31 '14 at 12:32
  • Where you are using this code, i mean inside which method. – InnocentKiller Mar 31 '14 at 12:38
  • onButtonClickListener when I am trying to pass the activity using intent. – Hetal Patel Mar 31 '14 at 12:40
  • then use `animMove.setAnimationListener(yourActivityname.this);` instead of `animMove.setAnimationListener(this);` – InnocentKiller Mar 31 '14 at 12:41
  • Like if your activity name is MainActivity.java then pass `animMove.setAnimationListener(MainActivity.this);` – InnocentKiller Mar 31 '14 at 12:44
  • Change `android:fromYDelta="50%p"` percentage of this parameter as per your requirement. – InnocentKiller Mar 31 '14 at 12:51
  • but then use animMove.setAnimationListener(yourActivityname.this); instead of animMove.setAnimationListener(this); this is what i had used but its also not working – Hetal Patel Mar 31 '14 at 13:02
  • RelativeLayout relrewards = (RelativeLayout) findViewById(R.id.relrewards); relrewards.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub /*overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); Intent intent = new Intent(MoreActivity.this, SignUpRewardMore.class); startActivity(intent);*/ Animation animMove; animMove = AnimationUtils.loadAnimation( getApplicationContext(), R.anim.move); animMove.setAnimationListener(MoreActivity.this); } }); – Hetal Patel Mar 31 '14 at 13:25
0

Define an animation in res/anim/slide_in_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="100%p" android:toYDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

and another at res/anim/slide_out_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime"/>

Then apply these after to call startActivity:

Intent i2 = new Intent(main.this, test.class);
startActivity(i2);
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
Amit Prajapati
  • 13,525
  • 8
  • 62
  • 84
0

Check my answer below if you are looking for Top-Bottom and Bottom-Top animations :

Android Animation Example

You can change the value of fromDelta and toDelta if you want from left-right and right-left animations.

Hope this helps.

Community
  • 1
  • 1
Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69