2014-05-19 144 views
1

我需要在android中滑动另一个布局。在android中滑动另一个布局

要求。

layout1覆盖了80%的屏幕,其余的被布局2占据。

enter image description here

。我需要能够滑动布局2上的布局1, 总宽度或滚动限制顶部为布局2应该是这样的布局1的 20%应该是可见的下方。

enter image description here

。然后我需要将布局2返回到其原始位置。

enter image description here

我已经试过可以滑动的教程包括

Sliding Menu by Jfeinstein

Slide Panel Layout - Android

,许多在互联网上提供的其他教程。

这些都不是能够提供我需要的,我试过很多自定义和差不多一个星期,

会有人帮助度过。

+0

你试过Viewpager:http://developer.android.com/training/animation/screen-slide.html – vjdhama

+0

感谢@vjdhama,我会尝试这一点,并让你知道。 –

+0

你怎么样看着一些滑动菜单库? [链接](https://github.com/jfeinstein10/SlidingMenu)等 – momoja

回答

1

明白了!最简单。没有图书馆,没有复杂的代码。使用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> 
相关问题