swiperefreshlayout

Android: CollapsingToolbarLayout and SwipeRefreshLayout get stuck

好久不见. 提交于 2019-11-26 06:59:05
问题 I use CollapsingToolbarLayout, RecyclerView and SwipeRefreshLayout together: Xml: <android.support.v4.widget.DrawerLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" xmlns:app=\"http://schemas.android.com/apk/res-auto\" android:id=\"@+id/drawer_layout\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\" android:fitsSystemWindows=\"true\"> <android.support.design.widget.CoordinatorLayout android:id=\"@+id/coordinator_layout\" android:layout_width=\

SwipeRefreshLayout setRefreshing() not showing indicator initially

社会主义新天地 提交于 2019-11-26 06:56:47
问题 I have a very simple layout but when I call setRefreshing(true) in onActivityCreated() of my fragment, it does not show initially. It only shows when I do a pull to refresh. Any ideas why it isn\'t showing up initially? Fragment xml: <android.support.v4.widget.SwipeRefreshLayout android:id=\"@+id/swipe_container\" xmlns:android=\"http://schemas.android.com/apk/res/android\" xmlns:tools=\"http://schemas.android.com/tools\" android:layout_width=\"match_parent\" android:layout_height=\"match

解决swipeRefreshLayout与RecyclerView的滑动冲突

蹲街弑〆低调 提交于 2019-11-26 01:13:16
网上给出的最多的滑动冲突解决办法思路:首先给RecyclerView添加滑动监听事件,其次获取recyclerView的第一个子布局的位置,如果你是上滑的话,recyclerView.getChildAt(0).getTop()获取的值肯定是个负数,当第一个item项出现,并且在顶部时swipeRefreshLayout才能启用,这样解决滑动冲突,但是这个方法在部分手机上不兼容。 网上的源码大概是这样的: recyclerView.addOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrolled (RecyclerView recyclerView, int dx, int dy) { super .onScrolled(recyclerView, dx, dy); int topRowVerticalPosition = (recyclerView == null || recyclerView.getChildCount() == 0 ) ? 0 : recyclerView.getChildAt( 0 ).getTop(); swipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0 ); }