Android拉下来从活动顶部显示视图

时间:2015-09-20 06:40:27

标签: android android-activity swipe pull-to-refresh

我有一项活动,当用户从上到下滑动时,活动顶部的视图会随着用户滑动的距离而下降。关于这个问题有类似的话题,但它们并不完全是我想要的。我怎样才能做到这一点。

在开始时,视图不属于活动。当用户开始拉动时。它将落在活动的顶部,整个视图将作为幻灯片的一部分下降。

1 个答案:

答案 0 :(得分:4)

这个答案来得很晚,但对其他人来说可能会有所帮助。您可以使用this library
结果如下:

enter image description here

只需更改您的布局:

<github.chenupt.dragtoplayout.DragTopLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent">

 <!--top view-->
 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:gravity="center"
     android:orientation="vertical">
     ...
 </LinearLayout>

 <!--content view-->
 <LinearLayout
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
     ...
 </LinearLayout>