How to disable touch events in SwipeRefreshLayout?

I am using Google SwipeRefreshLayout . and I have a few questions.

  • How to lock the touch screen while it is active onRefresh() ?
  • How to make progress in the center of rotation of the screen instead of the top during the update?

     swipeLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_status_info); swipeLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.CYAN); swipeLayout.setOnRefreshListener(this); @Override public void onRefresh() { clearTable(holidayTable); clearTable(cityayTable); setData(); } 
+5
source share
1 answer
  • If you want to block some view ( blockedView ) from receiving a touch event during an update, you can use this event in OnTouchListener:

     @Override public void onRefresh() { clearTable(holidayTable); clearTable(cityayTable); setData(); refreshing = true; } ... blockedView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { //consuming the touch if (refreshing) return true; //letting the touch propagate else return false; } }); 
  • set the desired offset in pixels using this method:

     swipeLayout.setProgressViewOffset(true, 0, offset); 
+1
source

Source: https://habr.com/ru/post/1209304/


All Articles