Tag: swiperefreshlayout

SwipeRefreshLayout和RecyclerView之间的差距

如何消除这两者之间的空隙? RecyclerView现在开始靠近屏幕的一半,从第一个元素到工具栏都有空白区域。 (只有当我添加足够的物品recyclerview开始顶部)。 我正在使用Kotlin和AnkoLayouts。 override fun createView(ui: AnkoContext): View = with(ui) { return relativeLayout { lparams(width = matchParent, height = matchParent) addItemButton = floatingActionButton { imageResource = android.R.drawable.ic_input_add }.lparams { margin = dip(10) alignParentBottom() alignParentEnd() alignParentRight() gravity = Gravity.BOTTOM or Gravity.END } swipeRefreshLayout = swipeRefreshLayout { rv = recyclerView { layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true) […]

仅在AppBarLayout完全展开时启用SwipeRefreshLayout

只有当AppBarLayout完全展开时,我怎样才能启用SwipeRefreshLayout 。 我只需要在下一个滑动手势上启用刷新模式。 现在,我尝试了 appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, final int verticalOffset) { refreshLayout.setEnabled(verticalOffset == 0); } }); 当然,它的作品! 但是它并不像我需要的那样。 此代码在用户继续滑动手势的同时立即启用刷新模式。 我只需要在AppBarLayout扩展后的下一次滑动时启用它。 谁知道如何做到这一点?

第一次尝试刷新的SwipeRefreshLayout动画无休止地运行

作为一个事实,我知道这不是Kotlin特有的事情。 我也遇到了Java同样的错误。 我试图把SwipeRefreshLayout放在FrameLayout ,没有任何作用。 我也试图把 srNewsFeedRefresh.isRefreshing = false 从下面的代码持续约2秒的任务,仍然没有效果。 我的xml: <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/srNewsFeedRefresh" android:layout_width="wrap_content" android:layout_height="wrap_content"> <android.support.v7.widget.RecyclerView android:id="@+id/rwNewsRecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical"/> 和片段代码: class NewsFeedFragment : Fragment(), NewsDelegateAdapter.onViewSelectedListener { override fun onItemSelected(url: String?) { Toast.makeText(context, "Love", Toast.LENGTH_SHORT).show() } private var mListener: OnFragmentInteractionListener? = null override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { return LayoutInflater .from(context) […]