androidslideslidingjfeinstein

Sliding one layout on another in android


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.


Solution

  • 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>