recyclerview

SwipeRefreshLayout 、RecyclerView 与 CoordinatorLayout 嵌套刷新滑动冲突的解决办法

∥☆過路亽.° 提交于 2019-12-02 13:56:58
SwipeRefreshLayout 与 CoordinatorLayout 嵌套刷新 1.设置 mSwipeRefreshLayout.setOnRefreshListener(this); 2. 动态设置SwipeRefreshLayout的是否可以刷新 setEnable(boolean isEnable); 3. 设置SwipRefreshLayout刷新图标的位置 setProgressViewOffset(true, -20, 100); 4. 监听 AppBarLayout Offset 变化,动态设置 SwipeRefreshLayout 是否可用 appBarLayout = (AppBarLayout) findViewById(R.id.appbar_layout); appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (verticalOffset >= 0) { mSwipeRefreshLayout.setEnabled(true); } else {

解决SwipeRefreshLayout与RecyclerView滑动冲突问题

牧云@^-^@ 提交于 2019-12-02 13:56:47
背景:高版本的编译环境中,SwipeRefreshLayout和RecyclerView并不存在滑动冲突问题,而我恰恰手里有个target是22的项目,当我按照正常的逻辑写完界面后,使用app发现滑动整个列表时两个控件发生冲突,本着快速解决上线任务的原则,直接百度. 网上的完美解决方案如下 : RecyclerView.OnScrollListener(){ @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int topRowVerticalPosition = (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop(); swipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0); } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } });

获取RecyclerView滑动的距离

ⅰ亾dé卋堺 提交于 2019-12-02 13:48:30
2019独角兽企业重金招聘Python工程师标准>>> 如果LayoutManager用的是LinearLayoutManager,强烈推荐下面的方法获取滑动距离 private int getScollYDistance() { LinearLayoutManager layoutManager = (LinearLayoutManager) mRecylerview.getLayoutManager(); int position = layoutManager.findFirstVisibleItemPosition(); View firstVisiableChildView = layoutManager.findViewByPosition(position); int itemHeight = firstVisiableChildView.getHeight(); return (position) * itemHeight - firstVisiableChildView.getTop(); } 转载于:https://my.oschina.net/u/1177694/blog/740455 来源: CSDN 作者: weixin_33989780 链接: https://blog.csdn.net/weixin_33989780/article/details

获取recyclerView 滑动距离

妖精的绣舞 提交于 2019-12-02 13:42:43
View getHeightView = new View(context); recycler_view.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { SoftPanUtil.hideSoftKeyboard(ChatDetailActivity.this); if (emojiKeyboard != null) { emojiKeyboard.hide(); } } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); getHeightView.scrollBy(0, dy); LogUtils.e("滑动高度" + getHeightView

RecyclerView 左滑(仿QQ左滑删除)

可紊 提交于 2019-12-02 13:27:41
一、效果图 二、实现步骤 1.添加依赖库 (Android/Gradle Scripts/build.gradle(Module:app)) compile 'com.android.support:recyclerview-v7:26.+' /* 版本号与 compile 'com.android.support:appcompat-v7:26.+' ,此句版本号为 26 .+ */ 2.RecyclerView布局 (activity_main.xml) <?xml version="1.0" encoding="utf-8"?> < RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" > < android.support.v7.widget.RecyclerView android:id = "@+id/recyclerview" android:background = "#EEEEEE" android:scrollbars = "vertical" android:layout_width = "match

Recyclerview下面跟随着控件

℡╲_俬逩灬. 提交于 2019-12-02 12:50:13
Recyclerview下面跟随着控件 效果 代码 注意点 推论 代码 效果 最后是实现了 RecyclerView 下面的控件会跟随着内容增加而下滑,并且最后超过屏幕时,下面的控件会粘在屏幕底部 代码 < LinearLayout xmlns : android = "http://schemas.android.com/apk/res/android" android : orientation = "vertical" android : id = "@+id/activity_main" android : layout_width = "match_parent" android : layout_height = "wrap_content" > < android . support . v7 . widget . RecyclerView android : layout_width = "match_parent" android : layout_height = "0dp" android : layout_weight = "1" > < / android . support . v7 . widget . RecyclerView > < LinearLayout android : layout_width = "match_parent"

RecyclerView简单使用

偶尔善良 提交于 2019-12-02 12:41:31
package com.example.recyclerviewtest; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager; import android.annotation.SuppressLint; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toast; import java.util.ArrayList; import java.util.List;

Android添加依赖recycleview错误

情到浓时终转凉″ 提交于 2019-12-02 11:49:21
Android添加依赖recycleview错误 在添加依赖的时候就发现自己出现这个错 ERROR: Failed to resolve: com.android.support:recycleview-v7:29.2.1 Show in Project Structure dialog Affected Modules: app 后面检查自己那条语句,语法好像已经变了 implementation'com.android.support:recycleview-v7:29.2.1' 把这句话换成这句话就可以成功创建 implementation'androidx.recyclerview:recyclerview:1.0.0' 最后syn now 就成功了 来源: https://blog.csdn.net/weixin_45598936/article/details/102757919

RecyclerView 通用适配器

£可爱£侵袭症+ 提交于 2019-12-02 06:07:58
原文地址:https://www.jianshu.com/p/82a74c9ccba5 public abstract class RVBaseAdapter<T> extends RecyclerView.Adapter<RVBaseAdapter.CommonViewHolder> { protected List<T> mBeans; protected Context mContext; protected boolean mAnimateItems = true; protected int mLastAnimatedPosition = -1; public RVBaseAdapter(Context context, List<T> beans) { mContext = context; mBeans = beans; } @Override public RVBaseAdapter.CommonViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(mContext); View view = inflater.inflate(getItemLayoutID(viewType), parent,