gpt4 book ai didi

android - 如何在滑动中刷新布局以刷新android

转载 作者:搜寻专家 更新时间:2023-11-01 08:33:45 24 4
gpt4 key购买 nike

每次我尝试在顶部滚动时,我都会在 swipeRefresh 内有一个回收器 View ,调用滑动刷新方法并刷新布局,但我只想在滚动到屏幕顶部时刷新布局。有没有人知道这个问题的答案。

感谢任何帮助,谢谢

我的布局如下图所示。

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<RelativeLayout
android:id="@+id/rel"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:scrollbars="vertical" />
</RelativeLayout>

</android.support.v4.widget.SwipeRefreshLayout>

最佳答案

我解决了我的问题。我不得不重新安排我的代码以使其正常工作。现在布局在到达屏幕顶部时刷新。

<RelativeLayout
android:id="@+id/rel"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/swipe_container"
android:scrollbars="vertical" />

</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>

关于android - 如何在滑动中刷新布局以刷新android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38389365/

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