SwipeRefreshLayout

public class SwipeRefreshLayout
extends ViewGroup implements NestedScrollingParent3, NestedScrollingParent2, NestedScrollingChild3, NestedScrollingChild2, NestedScrollingParent, NestedScrollingChild

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ androidx.swiperefreshlayout.widget.SwipeRefreshLayout


The SwipeRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture. The activity that instantiates this view should add an OnRefreshListener to be notified whenever the swipe to refresh gesture is completed. The SwipeRefreshLayout will notify the listener each and every time the gesture is completed again; the listener is responsible for correctly determining when to actually initiate a refresh of its content. If the listener determines there should not be a refresh, it must call setRefreshing(false) to cancel any visual indication of a refresh. If an activity wishes to show just the progress animation, it should call setRefreshing(true). To disable the gesture and progress animation, call setEnabled(false) on the view.

This layout should be made the parent of the view that will be refreshed as a result of the gesture and can only support one direct child. This view will also be made the target of the gesture and will be forced to match both the width and the height supplied in this layout. The SwipeRefreshLayout does not provide accessibility events; instead, a menu item must be provided to allow refresh of the content wherever this gesture is used.

Summary

Nested classes

interface SwipeRefreshLayout.OnChildScrollUpCallback

Classes that wish to override SwipeRefreshLayout.canChildScrollUp() method behavior should implement this interface. 

interface SwipeRefreshLayout.OnRefreshListener

Classes that wish to be notified when the swipe gesture correctly triggers a refresh should implement this interface. 

Constants

int DEFAULT

int DEFAULT_SLINGSHOT_DISTANCE

int LARGE

Inherited constants

Fields

protected int mFrom

protected int mOriginalOffsetTop

Inherited fields

Public constructors

SwipeRefreshLayout(Context context)

Simple constructor to use when creating a SwipeRefreshLayout from code.

SwipeRefreshLayout(Context context, AttributeSet attrs)

Constructor that is called when inflating SwipeRefreshLayout from XML.

Public methods

boolean canChildScrollUp()
boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean dispatchNestedPreFling(float velocityX, float velocityY)
boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow)
boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow, int type)

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow, int type)

Dispatch one step of a nested scroll in progress.

void dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow, int type, int[] consumed)

Dispatch one step of a nested scroll in progress.

boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow)
int getNestedScrollAxes()
int getProgressCircleDiameter()

Get the diameter of the progress circle that is displayed as part of the swipe to refresh layout.

int getProgressViewEndOffset()
int getProgressViewStartOffset()
boolean hasNestedScrollingParent()
boolean hasNestedScrollingParent(int type)

Returns true if this view has a nested scrolling parent for the given input type.

boolean isNestedScrollingEnabled()
boolean isRefreshing()
boolean onInterceptTouchEvent(MotionEvent ev)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)
boolean onNestedPreFling(View target, float velocityX, float velocityY)
void onNestedPreScroll(View target, int dx, int dy, int[] consumed)
void onNestedPreScroll(View target, int dx, int dy, int[] consumed, int type)

React to a nested scroll in progress before the target view consumes a portion of the scroll.

void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type)

React to a nested scroll in progress.

void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed)

React to a nested scroll in progress.

void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
void onNestedScrollAccepted(View child, View target, int axes, int type)

React to the successful claiming of a nested scroll operation.

void onNestedScrollAccepted(View child, View target, int axes)
boolean onStartNestedScroll(View child, View target, int axes, int type)

React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.

boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)
void onStopNestedScroll(View target)
void onStopNestedScroll(View target, int type)

React to a nested scroll operation ending.

boolean onTouchEvent(MotionEvent ev)
void requestDisallowInterceptTouchEvent(boolean b)
void setColorScheme(int... colors)

This method is deprecated. Use setColorSchemeResources(int)

void setColorSchemeColors(int... colors)

Set the colors used in the progress animation.

void setColorSchemeResources(int... colorResIds)

Set the color resources used in the progress animation from color resources.

void setDistanceToTriggerSync(int distance)

Set the distance to trigger a sync in dips

void setEnabled(boolean enabled)
void setNestedScrollingEnabled(boolean enabled)
void setOnChildScrollUpCallback(SwipeRefreshLayout.OnChildScrollUpCallback callback)

Set a callback to override canChildScrollUp() method.

void setOnRefreshListener(SwipeRefreshLayout.OnRefreshListener listener)

Set the listener to be notified when a refresh is triggered via the swipe gesture.

void setProgressBackgroundColor(int colorRes)

This method is deprecated. Use setProgressBackgroundColorSchemeResource(int)

void setProgressBackgroundColorSchemeColor(int color)

Set the background color of the progress spinner disc.

void setProgressBackgroundColorSchemeResource(int colorRes)

Set the background color of the progress spinner disc.

void setProgressViewEndTarget(boolean scale, int end)

The refresh indicator resting position is always positioned near the top of the refreshing content.

void setProgressViewOffset(boolean scale, int start, int end)

The refresh indicator starting and resting position is always positioned near the top of the refreshing content.

void setRefreshing(boolean refreshing)

Notify the widget that refresh state has changed.

void setSize(int size)

One of DEFAULT, or LARGE.

void setSlingshotDistance(int slingshotDistance)

Sets a custom slingshot distance.

boolean startNestedScroll(int axes, int type)

Begin a nestable scroll operation along the given axes, for the given input type.

boolean startNestedScroll(int axes)
void stopNestedScroll(int type)

Stop a nested scroll in progress for the given input type.

void stopNestedScroll()

Protected methods

int getChildDrawingOrder(int childCount, int i)
void onDetachedFromWindow()
void onLayout(boolean changed, int left, int top, int right, int bottom)
void onRestoreInstanceState(Parcelable state)
Parcelable onSaveInstanceState()

Inherited methods

Constants

DEFAULT

public static final int DEFAULT

Constant Value: 1 (0x00000001)

DEFAULT_SLINGSHOT_DISTANCE

public static final int DEFAULT_SLINGSHOT_DISTANCE

Constant Value: -1 (0xffffffff)

LARGE

public static final int LARGE

Constant Value: 0 (0x00000000)

Fields

mFrom

protected int mFrom

mOriginalOffsetTop

protected int mOriginalOffsetTop

Public constructors

SwipeRefreshLayout

public SwipeRefreshLayout (Context context)

Simple constructor to use when creating a SwipeRefreshLayout from code.

SwipeRefreshLayout

public SwipeRefreshLayout (Context context, 
                AttributeSet attrs)

Constructor that is called when inflating SwipeRefreshLayout from XML.

Public methods

canChildScrollUp

public boolean canChildScrollUp ()

Returns
boolean Whether it is possible for the child view of this layout to scroll up. Override this if the child view is a custom view.

dispatchNestedFling

public boolean dispatchNestedFling (float velocityX, 
                float velocityY, 
                boolean consumed)

Parameters
velocityX float

velocityY float

consumed boolean

Returns
boolean

dispatchNestedPreFling

public boolean dispatchNestedPreFling (float velocityX, 
                float velocityY)

Parameters
velocityX float

velocityY float

Returns
boolean

dispatchNestedPreScroll

public boolean dispatchNestedPreScroll (int dx, 
                int dy, 
                int[] consumed, 
                int[] offsetInWindow)

Parameters
dx int

dy int

consumed int

offsetInWindow int

Returns
boolean

dispatchNestedPreScroll

public boolean dispatchNestedPreScroll (int dx, 
                int dy, 
                int[] consumed, 
                int[] offsetInWindow, 
                int type)

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

Nested pre-scroll events are to nested scroll events what touch intercept is to touch. dispatchNestedPreScroll offers an opportunity for the parent view in a nested scrolling operation to consume some or all of the scroll operation before the child view consumes it.

Parameters
dx int: Horizontal scroll distance in pixels

dy int: Vertical scroll distance in pixels

consumed int: Output. If not null, consumed[0] will contain the consumed component of dx and consumed[1] the consumed dy.

offsetInWindow int: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.

type int: the type of input which cause this scroll event

Returns
boolean true if the parent consumed some or all of the scroll delta

dispatchNestedScroll

public boolean dispatchNestedScroll (int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int[] offsetInWindow, 
                int type)

Dispatch one step of a nested scroll in progress.

Implementations of views that support nested scrolling should call this to report info about a scroll in progress to the current nested scrolling parent. If a nested scroll is not currently in progress or nested scrolling is not enabled for this view this method does nothing.

Compatible View implementations should also call dispatchNestedPreScroll before consuming a component of the scroll event themselves.

Parameters
dxConsumed int: Horizontal distance in pixels consumed by this view during this scroll step

dyConsumed int: Vertical distance in pixels consumed by this view during this scroll step

dxUnconsumed int: Horizontal scroll distance in pixels not consumed by this view

dyUnconsumed int: Horizontal scroll distance in pixels not consumed by this view

offsetInWindow int: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.

type int: the type of input which cause this scroll event

Returns
boolean true if the event was dispatched, false if it could not be dispatched.

dispatchNestedScroll

public void dispatchNestedScroll (int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int[] offsetInWindow, 
                int type, 
                int[] consumed)

Dispatch one step of a nested scroll in progress.

Implementations of views that support nested scrolling should call this to report info about a scroll in progress to the current nested scrolling parent. If a nested scroll is not currently in progress or nested scrolling is not enabled for this view this method does nothing.

Compatible View implementations should also call dispatchNestedPreScroll before consuming a component of the scroll event themselves.

The original nested scrolling child (where the input events were received to start the scroll) must provide a non-null consumed parameter with values {0, 0}.

Parameters
dxConsumed int: Horizontal distance in pixels consumed by this view during this scroll step

dyConsumed int: Vertical distance in pixels consumed by this view during this scroll step

dxUnconsumed int: Horizontal scroll distance in pixels not consumed by this view

dyUnconsumed int: Horizontal scroll distance in pixels not consumed by this view

offsetInWindow int: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.

type int: the type of input which cause this scroll event

consumed int: Output. Upon this method returning, will contain the original values plus any scroll distances consumed by all of this view's nested scrolling parents up the view hierarchy. Index 0 for the x dimension, and index 1 for the y dimension

dispatchNestedScroll

public boolean dispatchNestedScroll (int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int[] offsetInWindow)

Parameters
dxConsumed int

dyConsumed int

dxUnconsumed int

dyUnconsumed int

offsetInWindow int

Returns
boolean

getNestedScrollAxes

public int getNestedScrollAxes ()

Returns
int

getProgressCircleDiameter

public int getProgressCircleDiameter ()

Get the diameter of the progress circle that is displayed as part of the swipe to refresh layout.

Returns
int Diameter in pixels of the progress circle view.

getProgressViewEndOffset

public int getProgressViewEndOffset ()

Returns
int The offset in pixels from the top of this view at which the progress spinner should come to rest after a successful swipe gesture.

getProgressViewStartOffset

public int getProgressViewStartOffset ()

Returns
int The offset in pixels from the top of this view at which the progress spinner should appear.

hasNestedScrollingParent

public boolean hasNestedScrollingParent ()

Returns
boolean

hasNestedScrollingParent

public boolean hasNestedScrollingParent (int type)

Returns true if this view has a nested scrolling parent for the given input type.

The presence of a nested scrolling parent indicates that this view has initiated a nested scroll and it was accepted by an ancestor view further up the view hierarchy.

Parameters
type int: the type of input which cause this scroll event

Returns
boolean whether this view has a nested scrolling parent

isNestedScrollingEnabled

public boolean isNestedScrollingEnabled ()

Returns
boolean

isRefreshing

public boolean isRefreshing ()

Returns
boolean Whether the SwipeRefreshWidget is actively showing refresh progress.

onInterceptTouchEvent

public boolean onInterceptTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

onMeasure

public void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int

onNestedFling

public boolean onNestedFling (View target, 
                float velocityX, 
                float velocityY, 
                boolean consumed)

Parameters
target View

velocityX float

velocityY float

consumed boolean

Returns
boolean

onNestedPreFling

public boolean onNestedPreFling (View target, 
                float velocityX, 
                float velocityY)

Parameters
target View

velocityX float

velocityY float

Returns
boolean

onNestedPreScroll

public void onNestedPreScroll (View target, 
                int dx, 
                int dy, 
                int[] consumed)

Parameters
target View

dx int

dy int

consumed int

onNestedPreScroll

public void onNestedPreScroll (View target, 
                int dx, 
                int dy, 
                int[] consumed, 
                int type)

React to a nested scroll in progress before the target view consumes a portion of the scroll.

When working with nested scrolling often the parent view may want an opportunity to consume the scroll before the nested scrolling child does. An example of this is a drawer that contains a scrollable list. The user will want to be able to scroll the list fully into view before the list itself begins scrolling.

onNestedPreScroll is called when a nested scrolling child invokes View.dispatchNestedPreScroll(int, int, int[], int[]). The implementation should report how any pixels of the scroll reported by dx, dy were consumed in the consumed array. Index 0 corresponds to dx and index 1 corresponds to dy. This parameter will never be null. Initial values for consumed[0] and consumed[1] will always be 0.

Parameters
target View: View that initiated the nested scroll

dx int: Horizontal scroll distance in pixels

dy int: Vertical scroll distance in pixels

consumed int: Output. The horizontal and vertical scroll distance consumed by this parent

type int: the type of input which cause this scroll event

onNestedScroll

public void onNestedScroll (View target, 
                int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int type)

React to a nested scroll in progress.

This method will be called when the ViewParent's current nested scrolling child view dispatches a nested scroll event. To receive calls to this method the ViewParent must have previously returned true for a call to onStartNestedScroll(View, View, int, int).

Both the consumed and unconsumed portions of the scroll distance are reported to the ViewParent. An implementation may choose to use the consumed portion to match or chase scroll position of multiple child elements, for example. The unconsumed portion may be used to allow continuous dragging of multiple scrolling or draggable elements, such as scrolling a list within a vertical drawer where the drawer begins dragging once the edge of inner scrolling content is reached.

Parameters
target View: The descendent view controlling the nested scroll

dxConsumed int: Horizontal scroll distance in pixels already consumed by target

dyConsumed int: Vertical scroll distance in pixels already consumed by target

dxUnconsumed int: Horizontal scroll distance in pixels not consumed by target

dyUnconsumed int: Vertical scroll distance in pixels not consumed by target

type int: the type of input which cause this scroll event

onNestedScroll

public void onNestedScroll (View target, 
                int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int type, 
                int[] consumed)

React to a nested scroll in progress.

This method will be called when the ViewParent's current nested scrolling child view dispatches a nested scroll event. To receive calls to this method the ViewParent must have previously returned true for a call to NestedScrollingParent2.onStartNestedScroll(View, View, int, int).

Both the consumed and unconsumed portions of the scroll distance are reported to the ViewParent. An implementation may choose to use the consumed portion to match or chase scroll position of multiple child elements, for example. The unconsumed portion may be used to allow continuous dragging of multiple scrolling or draggable elements, such as scrolling a list within a vertical drawer where the drawer begins dragging once the edge of inner scrolling content is reached.

This method is called when a nested scrolling child invokes NestedScrollingChild3.dispatchNestedScroll(int, int, int, int, int[], int, int[])} or one of methods it overloads.

An implementation must report how many pixels of the the x and y scroll distances were consumed by this nested scrolling parent by adding the consumed distances to the consumed parameter. If this View also implements NestedScrollingChild3, consumed should also be passed up to it's nested scrolling parent so that the parent may also add any scroll distance it consumes. Index 0 corresponds to dx and index 1 corresponds to dy.

Parameters
target View: The descendant view controlling the nested scroll

dxConsumed int: Horizontal scroll distance in pixels already consumed by target

dyConsumed int: Vertical scroll distance in pixels already consumed by target

dxUnconsumed int: Horizontal scroll distance in pixels not consumed by target

dyUnconsumed int: Vertical scroll distance in pixels not consumed by target

type int: the type of input which cause this scroll event

consumed int: Output. Upon this method returning, will contain the scroll distances consumed by this nested scrolling parent and the scroll distances consumed by any other parent up the view hierarchy

onNestedScroll

public void onNestedScroll (View target, 
                int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed)

Parameters
target View

dxConsumed int

dyConsumed int

dxUnconsumed int

dyUnconsumed int

onNestedScrollAccepted

public void onNestedScrollAccepted (View child, 
                View target, 
                int axes, 
                int type)

React to the successful claiming of a nested scroll operation.

This method will be called after onStartNestedScroll returns true. It offers an opportunity for the view and its superclasses to perform initial configuration for the nested scroll. Implementations of this method should always call their superclass's implementation of this method if one is present.

Parameters
child View: Direct child of this ViewParent containing target

target View: View that initiated the nested scroll

axes int: Flags consisting of ViewCompat.SCROLL_AXIS_HORIZONTAL, ViewCompat.SCROLL_AXIS_VERTICAL or both

type int: the type of input which cause this scroll event

onNestedScrollAccepted

public void onNestedScrollAccepted (View child, 
                View target, 
                int axes)

Parameters
child View

target View

axes int

onStartNestedScroll

public boolean onStartNestedScroll (View child, 
                View target, 
                int axes, 
                int type)

React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.

This method will be called in response to a descendant view invoking ViewCompat.startNestedScroll(View, int). Each parent up the view hierarchy will be given an opportunity to respond and claim the nested scrolling operation by returning true.

This method may be overridden by ViewParent implementations to indicate when the view is willing to support a nested scrolling operation that is about to begin. If it returns true, this ViewParent will become the target view's nested scrolling parent for the duration of the scroll operation in progress. When the nested scroll is finished this ViewParent will receive a call to onStopNestedScroll(View, int).

Parameters
child View: Direct child of this ViewParent containing target

target View: View that initiated the nested scroll

axes int: Flags consisting of ViewCompat.SCROLL_AXIS_HORIZONTAL, ViewCompat.SCROLL_AXIS_VERTICAL or both

type int: the type of input which cause this scroll event

Returns
boolean true if this ViewParent accepts the nested scroll operation

onStartNestedScroll

public boolean onStartNestedScroll (View child, 
                View target, 
                int nestedScrollAxes)

Parameters
child View

target View

nestedScrollAxes int

Returns
boolean

onStopNestedScroll

public void onStopNestedScroll (View target)

Parameters
target View

onStopNestedScroll

public void onStopNestedScroll (View target, 
                int type)

React to a nested scroll operation ending.

Perform cleanup after a nested scrolling operation. This method will be called when a nested scroll stops, for example when a nested touch scroll ends with a MotionEvent.ACTION_UP or MotionEvent.ACTION_CANCEL event. Implementations of this method should always call their superclass's implementation of this method if one is present.

Parameters
target View: View that initiated the nested scroll

type int: the type of input which cause this scroll event

onTouchEvent

public boolean onTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

requestDisallowInterceptTouchEvent

public void requestDisallowInterceptTouchEvent (boolean b)

Parameters
b boolean

setColorScheme

public void setColorScheme (int... colors)

This method is deprecated.
Use setColorSchemeResources(int)

Parameters
colors int

setColorSchemeColors

public void setColorSchemeColors (int... colors)

Set the colors used in the progress animation. The first color will also be the color of the bar that grows in response to a user swipe gesture.

setColorSchemeResources

public void setColorSchemeResources (int... colorResIds)

Set the color resources used in the progress animation from color resources. The first color will also be the color of the bar that grows in response to a user swipe gesture.

setDistanceToTriggerSync

public void setDistanceToTriggerSync (int distance)

Set the distance to trigger a sync in dips

setEnabled

public void setEnabled (boolean enabled)

Parameters
enabled boolean

setNestedScrollingEnabled

public void setNestedScrollingEnabled (boolean enabled)

Parameters
enabled boolean

setOnChildScrollUpCallback

public void setOnChildScrollUpCallback (SwipeRefreshLayout.OnChildScrollUpCallback callback)

Set a callback to override canChildScrollUp() method. Non-null callback will return the value provided by the callback and ignore all internal logic.

Parameters
callback SwipeRefreshLayout.OnChildScrollUpCallback: Callback that should be called when canChildScrollUp() is called.

setOnRefreshListener

public void setOnRefreshListener (SwipeRefreshLayout.OnRefreshListener listener)

Set the listener to be notified when a refresh is triggered via the swipe gesture.

Parameters
listener SwipeRefreshLayout.OnRefreshListener

setProgressBackgroundColor

public void setProgressBackgroundColor (int colorRes)

This method is deprecated.
Use setProgressBackgroundColorSchemeResource(int)

Parameters
colorRes int

setProgressBackgroundColorSchemeColor

public void setProgressBackgroundColorSchemeColor (int color)

Set the background color of the progress spinner disc.

setProgressBackgroundColorSchemeResource

public void setProgressBackgroundColorSchemeResource (int colorRes)

Set the background color of the progress spinner disc.

Parameters
colorRes int: Resource id of the color.

setProgressViewEndTarget

public void setProgressViewEndTarget (boolean scale, 
                int end)

The refresh indicator resting position is always positioned near the top of the refreshing content. This position is a consistent location, but can be adjusted in either direction based on whether or not there is a toolbar or actionbar present.

Parameters
scale boolean: Set to true if there is no view at a higher z-order than where the progress spinner is set to appear. Setting it to true will cause indicator to be scaled up rather than clipped.

end int: The offset in pixels from the top of this view at which the progress spinner should come to rest after a successful swipe gesture.

setProgressViewOffset

public void setProgressViewOffset (boolean scale, 
                int start, 
                int end)

The refresh indicator starting and resting position is always positioned near the top of the refreshing content. This position is a consistent location, but can be adjusted in either direction based on whether or not there is a toolbar or actionbar present.

Note: Calling this will reset the position of the refresh indicator to start.

Parameters
scale boolean: Set to true if there is no view at a higher z-order than where the progress spinner is set to appear. Setting it to true will cause indicator to be scaled up rather than clipped.

start int: The offset in pixels from the top of this view at which the progress spinner should appear.

end int: The offset in pixels from the top of this view at which the progress spinner should come to rest after a successful swipe gesture.

setRefreshing

public void setRefreshing (boolean refreshing)

Notify the widget that refresh state has changed. Do not call this when refresh is triggered by a swipe gesture.

Parameters
refreshing boolean: Whether or not the view should show refresh progress.

setSize

public void setSize (int size)

One of DEFAULT, or LARGE.

Parameters
size int

setSlingshotDistance

public void setSlingshotDistance (int slingshotDistance)

Sets a custom slingshot distance.

Parameters
slingshotDistance int: The distance in pixels that the refresh indicator can be pulled beyond its resting position. Use DEFAULT_SLINGSHOT_DISTANCE to reset to the default value.

startNestedScroll

public boolean startNestedScroll (int axes, 
                int type)

Begin a nestable scroll operation along the given axes, for the given input type.

A view starting a nested scroll promises to abide by the following contract:

The view will call startNestedScroll upon initiating a scroll operation. In the case of a touch scroll type this corresponds to the initial MotionEvent.ACTION_DOWN. In the case of touch scrolling the nested scroll will be terminated automatically in the same manner as ViewParent.requestDisallowInterceptTouchEvent(boolean). In the event of programmatic scrolling the caller must explicitly call stopNestedScroll(int) to indicate the end of the nested scroll.

If startNestedScroll returns true, a cooperative parent was found. If it returns false the caller may ignore the rest of this contract until the next scroll. Calling startNestedScroll while a nested scroll is already in progress will return true.

At each incremental step of the scroll the caller should invoke dispatchNestedPreScroll once it has calculated the requested scrolling delta. If it returns true the nested scrolling parent at least partially consumed the scroll and the caller should adjust the amount it scrolls by.

After applying the remainder of the scroll delta the caller should invoke dispatchNestedScroll, passing both the delta consumed and the delta unconsumed. A nested scrolling parent may treat these values differently. See NestedScrollingParent2.onNestedScroll(View, int, int, int, int, int).

Parameters
axes int: Flags consisting of a combination of ViewCompat.SCROLL_AXIS_HORIZONTAL and/or ViewCompat.SCROLL_AXIS_VERTICAL.

type int: the type of input which cause this scroll event

Returns
boolean true if a cooperative parent was found and nested scrolling has been enabled for the current gesture.

startNestedScroll

public boolean startNestedScroll (int axes)

Parameters
axes int

Returns
boolean

stopNestedScroll

public void stopNestedScroll (int type)

Stop a nested scroll in progress for the given input type.

Calling this method when a nested scroll is not currently in progress is harmless.

Parameters
type int: the type of input which cause this scroll event

stopNestedScroll

public void stopNestedScroll ()

Protected methods

getChildDrawingOrder

protected int getChildDrawingOrder (int childCount, 
                int i)

Parameters
childCount int

i int

Returns
int

onDetachedFromWindow

protected void onDetachedFromWindow ()

onLayout

protected void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

Parameters
changed boolean

left int

top int

right int

bottom int

onRestoreInstanceState

protected void onRestoreInstanceState (Parcelable state)

Param