【问题标题】:how to scroll pull to refresh scrollview in normal scrollview如何滚动拉动以刷新普通滚动视图中的滚动视图
【发布时间】:2014-04-10 01:06:14
【问题描述】:

这是我的布局 xml。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/garae_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:fillViewport="true"
android:focusableInTouchMode="false" >
   <RelativeLayout>
      ...
      <com.handmark.pulltorefresh.library.PullToRefreshScrollView>
         <LinearLayout/>
      </com.handmark.pulltorefresh.library.PullToRefreshScrollView>
   </RelativeLayout>
</ScrollView>

我已经尝试过此链接中的解决方案: ScrollView Inside ScrollView

但是,它没有用。如何使用子 PullToRefreshScrollView? 请帮帮我。

【问题讨论】:

    标签: android layout refresh scrollview pull


    【解决方案1】:

    如果我理解您的问题,您希望在 Scrollview 中实现 Pull 以刷新。相反,要使用您正在使用的库,我建议您实现 SwipeRefreshLayout https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html 它是一种像 Google+ 或 Gmail 应用程序一样实现下拉刷新的布局。

    这是在您的 xml 中实现 SwipeRefreshLayout 的示例:

        <?xml version="1.0" encoding="utf-8"?>
    
        <FrameLayout
            android:layout_width="match_parent" android:layout_height="match_parent"
            xmlns:android="http://schemas.android.com/apk/res/android" >
    
            <android.support.v4.widget.SwipeRefreshLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/swipe_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
    
              <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:tools="http://schemas.android.com/tools"
                 android:id="@+id/garae_scroll"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" >
    
             </ScrollView>
    
           </android.support.v4.widget.SwipeRefreshLayout>
    </FrameLayout>
    

    注意

    强烈不建议将 Scrollview/Listview 放在 Scrollview/Listview 中。第一个原因是关于性能,Romain Guy 在一个视频中解释说https://www.youtube.com/watch?v=wDBM6wVEO70

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多