Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slide up activity

I have an activity and another activity. I want my first activity to end when I slide up the screen. The animation should be like the activity is sliding up too. Like the notification screen. Is that possible? I have done many Google searches before posting this question, but could not get anything.

P.S - I don't want this to be seen as a casual question since there is no code shown. I just need some point to start and I am completely baffled.

like image 368
rrrocky Avatar asked Sep 15 '13 22:09

rrrocky


People also ask

How do you slide text on Android?

On your Android phone or tablet, install Gboard. Open any app that you can type with, like Gmail or Keep. Tap where you can enter text. Slide your finger across the letters to spell the word you want.

How do you animate a view?

Create ImageView in the activity_main. xml along with buttons that will add animation to the view. Navigate to the app > res > layout > activity_main. xml.

What is transition animation in Android?

Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.


1 Answers

make an anim folder in res->

Make an xml file in anim folder slide_up_info.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
    android:duration="500"
    android:fromYDelta="100%p"
    android:toYDelta="0" />
</set>

slide_down_info.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
    android:duration="500"
    android:fromYDelta="0%p"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toYDelta="100%p" />
</set>

no_change.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="0%p" android:toYDelta="0" android:duration="500"/>
</set>

Now when you want to activity up then write below code

Intent intent_info = new Intent(MainActivity.this,ToActivity.class);
startActivity(intent_info);
overridePendingTransition(R.anim.slide_up_info,R.anim.no_change);

For down Activity animation

Intent intent_home=new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent_home);
overridePendingTransition(R.anim.no_change,R.anim.slide_down_info);
like image 103
PankajAndroid Avatar answered Oct 21 '22 11:10

PankajAndroid