Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change of activity with the slide of the finger

I wonder how to change the activity with the slide of the finger, or slide your finger from right to left and change the activity, the way we saw the pictures on smartphones.

Anyone know?

Cumpz

like image 208
Kiotto Avatar asked Jan 31 '12 11:01

Kiotto


3 Answers

See the following link

http://savagelook.com/blog/android/swipes-or-flings-for-navigation-in-android

like image 72
Rishi Avatar answered Sep 27 '22 21:09

Rishi


I wrote a demo at https://github.com/chenjishi/SlideActivity, all you need to do is extend the SlidingActivity in the project and you get a slide effect,here is the screenshot: enter image description here

#### old method

1.make the activity transparent

<style name="Theme.Transparent" parent="@android:style/Theme.Translucent.NoTitleBar">
    <item name="android:windowAnimationStyle">@style/activityAnimation</item>
</style>

2.use SlidingPaneLayout

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.SlidingPaneLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slide_panel"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<View android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_gravity="left"/>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#E6E6E6"
        android:orientation="vertical">
</LinearLayout>

3.so here you get you want enter image description here

you can slide with your finger to move the activity, and you also can destroy it when sliding to the right most of screen.

like image 20
Jishi Chen Avatar answered Sep 27 '22 21:09

Jishi Chen


Use a ViewPager to achieve what you are looking for. Here is a tutorial.

like image 42
Ragunath Jawahar Avatar answered Sep 27 '22 21:09

Ragunath Jawahar