-- Surface View End -- </com.daimajia.swipe.SwipeLayout 第三步、在Activity中得到SwipeLayout实例....SwipeLayout swipeLayout = (SwipeLayout) view.findViewById(R.id.swipelayout); //设置侧拉的模式 swipeLayout.setShowMode...(SwipeLayout.ShowMode.LayDown); //如果布局文件里面有layout_gravity属性,这句可以忽略 //swipeLayout.addDrag(SwipeLayout.DragEdge.Left...swipeLayout = (SwipeLayout) view.findViewById(R.id.swipelayout); //这里写对布局中控件的一些初始化 swipeLayout.setShowMode...(new SwipeLayout.SwipeListener() { @Override public void onClose(SwipeLayout layout) { //when the
个人感觉SwipeLayout最好用。下面介绍怎么使用。...<com.daimajia.swipe.SwipeLayout xmlns:swipe="http://schemas.android.com/apk/res-auto" xmlns:android...swipeLayout = (SwipeLayout) v.findViewById(R.id.swipe); swipeLayout.addSwipeListener(new SimpleSwipeListener...() { @Override public void onOpen(SwipeLayout layout) {//当隐藏的删除menu被打开的时候的回调函数 // TODO Auto-generated...(new SwipeLayout.DoubleClickListener() { @Override public void onDoubleClick(SwipeLayout layout, boolean
此demo使用开源项目SwipeLayout实现该功能。关于SwipeLayout的常用设置和属性,这里都做介绍,下面进入正题。...说明:最外层是我们的SwipeLayout,里面是两个LinearLayout,第一层是我们的页面布局,第二层是我们的侧边划出来的布局。...swipeLayout = (SwipeLayout) itemView.findViewById(getSwipeLayoutResourceId(position)); // 设置滑动是否可用,默认为...(new SwipeLayout.SwipeListener() { @Override public void onStartOpen(SwipeLayout layout) { // Log.e...(true); // SwipeLayout单击事件,可替代ListView的OnitemClickListener事件. swipeLayout.setOnClickListener(new View.OnClickListener
Android自定义SwipeLayout仿QQ侧滑条目,供大家参考,具体内容如下 先看动图 ?..." / </RelativeLayout swipelayout.xml <?...) findViewById(R.id.swipelayout); mSwipeLayout.setOnClickListener(new SwipeLayout.OnClickListener...swipeLayout); void onLeftClose(SwipeLayout swipeLayout); void onRightOpen(SwipeLayout swipeLayout);...void onRightClose(SwipeLayout swipeLayout); } public interface OnClickListener { void onClick(View view
完整示例代码请看: GitHub 地址 主要源码: public class SwipeLayout extends FrameLayout { public static final int...View mTopView; private View mBottomView; private ViewDragHelper mViewDragHelper; public SwipeLayout...(Context context) { this(context, null); } public SwipeLayout(Context context, AttributeSet...attrs) { this(context, attrs, 0); } public SwipeLayout(Context context, AttributeSet...swipeLayout); void onCloseListener(SwipeLayout swipeLayout); void onClickListener(
> SwipeLayout /** * 侧拉删除控件 * @author poplar * */ public class SwipeLayout extends FrameLayout...mSwipeLayout); void onOpen(SwipeLayout mSwipeLayout); void onDraging(SwipeLayout mSwipeLayout); /.../ 要去关闭 void onStartClose(SwipeLayout mSwipeLayout); // 要去开启,这时候需要其他开启的关闭 void onStartOpen(SwipeLayout...mSwipeLayout); } public SwipeLayout(Context context) { this(context, null); } public SwipeLayout...} @Override public void onDraging(SwipeLayout mSwipeLayout) { } @Override public void onClose(SwipeLayout
> SwipeLayout /** * 侧拉删除控件 * @author poplar * */ public class SwipeLayout extends FrameLayout {...mSwipeLayout); void onOpen(SwipeLayout mSwipeLayout); void onDraging(SwipeLayout mSwipeLayout); /.../ 要去关闭 void onStartClose(SwipeLayout mSwipeLayout); // 要去开启,这时候需要其他开启的关闭 void onStartOpen(SwipeLayout...mSwipeLayout); } public SwipeLayout(Context context) { this(context, null); } public SwipeLayout...} @Override public void onDraging(SwipeLayout mSwipeLayout) { } @Override public void onClose(SwipeLayout
好了,直接上自定义的SwipeLayout源码: /** * Created by mChenys on 2015/12/26. */ public class SwipeLayout extends...需要考虑2点: 1.在自定义SwipeLayout控件内需要处理3种状态,打开,关闭,拖拽. 2.需要添加一个侧滑监听接口,用于对外暴露当前SwipeLayout的打开,关闭,拖拽,将要打开,将要关闭这...{ //关闭 void onClose(SwipeLayout mSwipeLayout); //打开 void onOpen(SwipeLayout mSwipeLayout); //正在侧拉...void onDraging(SwipeLayout mSwipeLayout); //开始要去关闭 void onStartClose(SwipeLayout mSwipeLayout);...,需要将集合中的之前打开的SwipeLayout统统关闭 for (SwipeLayout swipeLayout : mOpenItem) { swipeLayout.close(); } mOpenItem.clear
先附上图: image.png xml资源文件 <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/<em>swipeLayout</em>...>(this, android.R.layout.simple_list_item_1, getData())); /*获取SwipeRefreshLayout*/ <em>swipeLayout</em>...= (SwipeRefreshLayout) findViewById(R.id.<em>swipeLayout</em>); /*设置下拉刷新监听器*/ <em>swipeLayout</em>.setOnRefreshListener...SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { <em>swipeLayout</em>.postDelayed...Runnable() { @Override public void run() { <em>swipeLayout</em>.setRefreshing
onInterceptTouchEvent 返回:让ViewDragHelper判断是否需要拦截事件 6.0 onTouchEvent 返回true 并且让ViewDragHelper分析事件 具体代码: 布局: <cn.itheima.swipelayout.SwipeLayout...padding="10dp" android:text="删除" android:textSize="20sp" / </LinearLayout </cn.itheima.swipelayout.SwipeLayout...SwipeLayout 代码: public class SwipeLayout extends FrameLayout { private ViewDragHelper mDragHelper...; public SwipeLayout(Context context) { super(context); initView(); } public SwipeLayout(...=2){ throw new RuntimeException("SwipeLayout 必须存放两个子控件"); } if (!
//根据滑动角度判断用户是滑出SwipeLayout还是Listview double angle = Math.atan((ev.getY() - pressY) / (ev.getX...interceptStatus = SWIPE_MENU_OPEN; //标记为SwipeLayout滑动 return false; } 3点击事件处理...= SwipeLayout.Status.Close) { //如果当前有打开或者正在打开的SwipeLayout Log.d(TAG, "currentSwipeLayout.getOpenStatus...中,即用户是否点击这个SwipeLayout,有就不拦截时间交由SwipeLayout自己处理 if (rect.contains(pressX, pressY)) {...//判断当前点击X Y坐标是否在当前SwipeLayout中,即用户是否点击这个SwipeLayout,有就不拦截时间交由SwipeLayout自己处理 if (rect.contains
解决办法就是,我们自己创建一个 SwipeLayout,然后人为地插入顶层 View 中,放置在 DecorView 和其下面的 LinearLayout 中间,随着手指的滑动,不断改变 SwipeLayout...我们在 Activity 的 onPostCreate 方法中调用swipeLayout.replaceLayer 替换我们的 SwipeLayout,代码如下: public void replaceLayer...ViewGroup.LayoutParams(-1, -1); //把根 View 下面原来的第一个 View 删除 root.removeView(content); //把 content 添加到 SwipeLayout...this.addView(content, params2); //再把 SwipeLayout 添加到根 View 里面 root.addView(this, params); sideWidth
MainActivity extends Activity implements SwipeRefreshLayout.OnRefreshListener { private SwipeRefreshLayout swipeLayout...savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); swipeLayout...swipeLayout.setOnRefreshListener(this); swipeLayout.setColorScheme(android.R.color.holo_blue_bright...swipeLayout.setRefreshing(false); } }, 3000); } } xml实现activity_main.xml: <android.support.v4
android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; public class SwipeLayout...extends ViewGroup{ public static String TAG = "SwipeLayout"; //可以滚动的距离 int mSwipeWidth; PointF firstPoint...PointF lastPoint; float mTouchSlop; ValueAnimator openAnimator; ValueAnimator closeAnimator; public SwipeLayout...(Context context) { this(context,null); } public SwipeLayout(Context context, AttributeSet attrs) { super...android:id="@+id/swipeLayout" android:layout_width="200dp" android:layout_height="wrap_content" android
如果你在想要刷新功能,在CoordinatorLayout外面套了一个SwipeRefreshLayout,一不小心就触发了刷新~~(自己体会) 解决方案:这个问题可以通过对AppBarLayout的监听,设置swipeLayout...mAblAppBar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> { if (verticalOffset == 0) { swipeLayout.setEnabled...swipeLayout.isRefreshing()) { swipeLayout.setEnabled(false); } } }); 源码地址 Github
= null) { isLoadMore = true; //设置在加载更多的时候swipeLayout不允许加载更多,同时需要设置在加载更多完毕的时候允许...swipeLayout加载更多 setRefreshEnabled(false); mLayoutManager.scrollToPosition(mLayoutManager.findLastVisibleItemPosition...为防止频繁网络请求,isLoadMore为false才可再次请求更多数据 */ private void setLoadMoreCompleted() { //因为在加载更多的时候设置swipeLayout...不允刷新, // 所以加载更多完毕的时候需要设置允许swipeLayout允许刷新 setRefreshEnabled(true); isLoadMore = false
context=".MainActivity"> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/<em>swipeLayout</em>...init(); //设置SwipeRefreshLayout mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.<em>swipeLayout</em>
com.iosdevlog.qiushibaike.MainActivity"> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/<em>swipeLayout</em>...mRecyclerView = findViewById(R.id.recycleview) mSwipeRefreshLayout = findViewById(R.id.<em>swipeLayout</em>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/<em>swipelayout</em>
layout_height="match_parent" //在这里是实现右侧的菜单,根据你们的项目随便添加 </LinearLayout </wellijohn.org.swipevg.SwipeLayout
领取专属 10元无门槛券
手把手带您无忧上云