2

I need to slide one layout on another in android.

Requirments.

1 . layout1 covers 80% of the screen and the rest is occupied by layout 2.

enter image description here

2 . I need to be able to slide layout 2 on top of layout 1, total width or scrollable limit for layout 2 should be such that 20% of layout 1 should be visible below.

enter image description here

3 . Then i need to slide layout 2 back to its original position.

enter image description here

I have tried may sliding tutorials including

Sliding Menu by Jfeinstein

Slide Panel Layout - Android

and many other tutorials available in the internet.

None of these was able to provide what i need, i tried many customizations and spent almost a week,

could someone help.

Shamnad P S
  • 1,095
  • 2
  • 15
  • 43
  • Have you tried Viewpager : http://developer.android.com/training/animation/screen-slide.html – vjdhama May 19 '14 at 08:28
  • thanks @vjdhama , i will try this and let you know. – Shamnad P S May 19 '14 at 09:43
  • how about you try looking at some Sliding Menu libraries? [link](https://github.com/jfeinstein10/SlidingMenu) among others – momoja May 19 '14 at 10:16
  • @vjdhama I tried it, but the second layout when slided covers the whole window, i want it to cover only 3/4 th of the window. – Shamnad P S May 20 '14 at 04:32
  • @user1481694 I tried it, but the second layout when slided covers the whole window, i want it to cover only 3/4 th of the window. – Shamnad P S May 20 '14 at 04:48
  • yes, that should be okay, because there should be a function there where you can set how much of the main screen can the sliding layout cover.. try slidingLayout. and lookup offset – momoja May 20 '14 at 07:43
  • Take a look at this : http://blog.neteril.org/blog/2013/10/10/framelayout-your-best-ui-friend/ – bashizip Jul 24 '14 at 20:06

1 Answers1

5

Got It!!.. Simplicity at its best. No libraries, No complicated codes. Use SimplePaneLayout.

Just set the android:layout_marginLeft to a suitable value. :) Awesome :)

<android.support.v4.widget.SlidingPaneLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/slidingpanelayout">

        <LinearLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="#CCC"
                  android:orientation="horizontal"
                  android:id="@+id/fragment_firstpane"/>

        <LinearLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="#000"
                  android:orientation="horizontal"
                  android:layout_marginLeft="40dp"
                  android:id="@+id/fragment_secondpane"/>

    </android.support.v4.widget.SlidingPaneLayout>
Shamnad P S
  • 1,095
  • 2
  • 15
  • 43