gpt4 book ai didi

android - 如何在普通 ScrollView 中滚动拉动刷新 ScrollView

转载 作者:行者123 更新时间:2023-12-02 21:18:08 28 4
gpt4 key购买 nike

这是我的布局 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?请帮助我。

最佳答案

如果我理解你的问题,你想在你的 ScrollView 中实现拉动刷新。相反,要使用您正在使用的库,我建议您实现 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 中解释了这一点。

关于android - 如何在普通 ScrollView 中滚动拉动刷新 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22976823/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com