在android中将一种布局滑动到另一种布局

Sha*_*P S 3 android slide sliding jfeinstein

我需要在 android 中将一种布局滑动到另一种布局上。

要求。

1 . layout1覆盖了 80% 的屏幕,其余的由layout 2占据。

在此处输入图片说明

2 . 我需要能够在布局 1之上滑动 布局 2布局 2 的总宽度或可滚动限制应该使得 布局 1 的 20%应该在下方可见。

在此处输入图片说明

3 . 然后我需要将布局 2其原始位置。

在此处输入图片说明

我试过可能滑动教程包括

Jfeinstein 的滑动菜单

滑动面板布局 - Android

以及互联网上提供的许多其他教程。

这些都不能提供我需要的东西,我尝试了很多自定义并花了将近一周的时间,

有人可以帮忙吗。

Sha*_*P S 5

明白了!!...最好的简单。没有库,没有复杂的代码。使用 SimplePaneLayout。

只需将 android:layout_marginLeft 设置为合适的值。:) 惊人的 :)

<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>
Run Code Online (Sandbox Code Playgroud)