SlidingPaneLayout


public class SlidingPaneLayout extends ViewGroup implements Openable


SlidingPaneLayout provides a horizontal, multi-pane layout for use at the top level of a UI. A left (or start) pane is treated as a content list or browser, subordinate to a primary detail view for displaying content.

Child views overlap if their combined width exceeds the available width in the SlidingPaneLayout. Each of child views is expand out to fill the available width in the SlidingPaneLayout. When this occurs, the user may slide the topmost view out of the way by dragging it, and dragging back it from the very edge.

Thanks to this sliding behavior, SlidingPaneLayout may be suitable for creating layouts that can smoothly adapt across many different screen sizes, expanding out fully on larger screens and collapsing on smaller screens.

SlidingPaneLayout is distinct from a navigation drawer as described in the design guide and should not be used in the same scenarios. SlidingPaneLayout should be thought of only as a way to allow a two-pane layout normally used on larger screens to adapt to smaller screens in a natural way. The interaction patterns expressed by SlidingPaneLayout imply a physicality and direct information hierarchy between panes that does not necessarily exist in a scenario where a navigation drawer should be used instead.

Appropriate uses of SlidingPaneLayout include pairings of panes such as a contact list and subordinate interactions with those contacts, or an email thread list with the content pane displaying the contents of the selected thread. Inappropriate uses of SlidingPaneLayout include switching between disparate functions of your app, such as jumping from a social stream view to a view of your personal profile - cases such as this should use the navigation drawer pattern instead. (DrawerLayout implements this pattern.)

Like LinearLayout, SlidingPaneLayout supports the use of the layout parameter layout_weight on child views to determine how to divide leftover space after measurement is complete. It is only relevant for width. When views do not overlap weight behaves as it does in a LinearLayout.

Summary

Nested types

Listener for monitoring events about sliding panes.

No-op stubs for PanelSlideListener.

Constants

static final int

The user cannot swipe between list and detail panes, though the app can open or close the detail pane programmatically.

static final int

The detail pane is locked in a closed position.

static final int

The detail pane is locked in an open position.

static final int

User can freely swipe between list and detail panes.

Public constructors

SlidingPaneLayout(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyle
)

Public methods

void

Adds the specified listener to the list of listeners that will be notified of panel slide events.

void
addView(
    @NonNull View child,
    int index,
    @Nullable ViewGroup.LayoutParams params
)
boolean

This method is deprecated.

Renamed to isSlideable - this method is going away soon!

void

Close the detail view if it is currently slideable.

boolean

Close the detail view if it is currently slideable.

void
void
ViewGroup.LayoutParams
@ColorInt int

This method is deprecated.

This field is no longer populated by SlidingPaneLayout

final int

Get the lock mode used to control over the swipe behavior.

@Px int
@ColorInt int

This method is deprecated.

This field is no longer populated by SlidingPaneLayout.

boolean

Check if the detail view is completely open.

boolean

Check if both the list and detail view panes in this layout can fully fit side-by-side.

boolean
boolean
void

Open the detail view if it is currently slideable.

boolean

Open the detail view if it is currently slideable.

void

Removes the specified listener from the list of listeners that will be notified of panel slide events.

void
void
requestChildFocus(View child, View focused)
void

This method is deprecated.

SlidingPaneLayout no longer uses this field.

final void
setLockMode(int lockMode)

Set the lock mode that controls how the user can swipe between the panes.

void

This method is deprecated.

Use addPanelSlideListener

void
setParallaxDistance(@Px int parallaxBy)

Set a distance to parallax the lower pane by when the upper pane is in its fully closed state.

void

This method is deprecated.

Renamed to setShadowDrawableLeft to support LTR (left to right language) and setShadowDrawableRight to support RTL (right to left language) during opening/closing.

void

Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.

void

Set a drawable to use as a shadow cast by the left pane onto the right pane during opening/closing to support right to left language.

void

This method is deprecated.

Renamed to setShadowResourceLeft to support LTR (left to right language) and setShadowResourceRight to support RTL (right to left language) during opening/closing.

void

Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.

void

Set a drawable to use as a shadow cast by the left pane onto the right pane during opening/closing to support right to left language.

void

This method is deprecated.

SlidingPaneLayout no longer uses this field.

void

This method is deprecated.

Renamed to closePane - this method is going away soon!

void

This method is deprecated.

Renamed to openPane - this method is going away soon!

Protected methods

boolean
canScroll(View v, boolean checkV, int dx, int x, int y)

Tests scrollability within child views of v given a delta of dx.

boolean
boolean
drawChild(Canvas canvas, View child, long drawingTime)
ViewGroup.LayoutParams
ViewGroup.LayoutParams
void
void
void
onLayout(boolean changed, int l, int t, int r, int b)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
Parcelable
void
onSizeChanged(int w, int h, int oldw, int oldh)

Inherited Constants

From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
From android.view.ViewGroup
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

Inherited methods

From android.view.View
void
void
void
ViewPropertyAnimator
void
void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void
boolean
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
int
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    Bundle arguments
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow
)
boolean
void
drawableHotspotChanged(float x, float y)
final OnBackInvokedDispatcher
final T
<T extends View> findViewById(int id)
final T
<T extends View> findViewWithTag(Object tag)
boolean

This method is deprecated.

void
forceHasOverlappingRendering(boolean hasOverlappingRendering)
void
void
generateDisplayHash(
    String hashAlgorithm,
    Rect bounds,
    Executor executor,
    DisplayHashResultCallback callback
)
static int
View.AccessibilityDelegate
int
AccessibilityNodeProvider
CharSequence
int
int
String
String
float
Animation
Matrix
IBinder
int[]
Map<IntegerInteger>
String[]
final AutofillId
int
AutofillValue
Drawable
BlendMode
ColorStateList
PorterDuff.Mode
int
final int
float
int
float
Rect
boolean
final boolean
final ContentCaptureSession
CharSequence
final Context
ContextMenu.ContextMenuInfo
final boolean
static int
getDefaultSize(int size, int measureSpec)
Display
final int[]
Bitmap

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
long
float
int
boolean
boolean
int
ArrayList<View>
getFocusables(int direction)
void
Drawable
int
BlendMode
ColorStateList
PorterDuff.Mode
boolean
getGlobalVisibleRect(Rect r, Point globalOffset)
Handler
float
float
float
float
Runnable
final boolean
final int
void
getHitRect(Rect outRect)
int
int
Drawable
Drawable
int
int
int
int
boolean
KeyEvent.DispatcherState
int
int
int
ViewGroup.LayoutParams
final int
float
int
final boolean
void
getLocationInSurface(int[] location)
void
getLocationInWindow(int[] outLocation)
void
getLocationOnScreen(int[] outLocation)
Matrix
final int
final int
final int
final int
final int
int
int
int
int
int
int
int
int
View.OnFocusChangeListener
int
ViewOutlineProvider
int
int
ViewOverlay
int
int
int
int
int
int
final ViewParent
ViewParent
float
float
PointerIcon
final List<Rect>
String[]
Resources
final boolean
final int
float
int
AttachedSurfaceControl
View
WindowInsets
float
float
float
float
float
int
int
int
int
int
int
final int
final int
int
int
final CharSequence
StateListAnimator
int
int
List<Rect>
int

This method is deprecated.

Object
int
int
CharSequence
final int
float
int
TouchDelegate
ArrayList<View>
float
String
float
float
float
long
int
int
Drawable
Drawable
int
ViewTranslationResponse
ViewTreeObserver
int
final int
int
WindowId
WindowInsetsController
int

This method is deprecated.

IBinder
int
void
float
float
float
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
static View
inflate(Context context, int resource, ViewGroup root)
void

This method is deprecated.

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean

This method is deprecated.

boolean
boolean
final boolean
final boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
View
keyboardNavigationClusterSearch(View currentCluster, int direction)
final void
measure(int widthMeasureSpec, int heightMeasureSpec)
static int[]
mergeDrawableStates(int[] baseState, int[] additionalState)
void
offsetLeftAndRight(int offset)
void
offsetTopAndBottom(int offset)
void
void
WindowInsets
void
boolean
boolean
void
void
InputConnection
void
onCreateViewTranslationRequest(
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onCreateVirtualViewTranslationRequests(
    long[] virtualIds,
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onDisplayHint(int hint)
boolean
void
onDraw(Canvas canvas)
void
final void
boolean
void
void
void
onFocusChanged(
    boolean gainFocus,
    int direction,
    Rect previouslyFocusedRect
)
boolean
void
onHoverChanged(boolean hovered)
boolean
void
void
boolean
onKeyDown(int keyCode, KeyEvent event)
boolean
onKeyLongPress(int keyCode, KeyEvent event)
boolean
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
boolean
onKeyPreIme(int keyCode, KeyEvent event)
boolean
onKeyShortcut(int keyCode, KeyEvent event)
boolean
onKeyUp(int keyCode, KeyEvent event)
void
onOverScrolled(
    int scrollX,
    int scrollY,
    boolean clampedX,
    boolean clampedY
)
void
onPointerCaptureChange(boolean hasCapture)
void
void
onProvideAutofillStructure(ViewStructure structure, int flags)
void
void
void
void
ContentInfo
void
onRtlPropertiesChanged(int layoutDirection)
void
onScreenStateChanged(int screenState)
void
onScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
onScrollChanged(int l, int t, int oldl, int oldt)
boolean
onSetAlpha(int alpha)
void
boolean
void
void
void
onVisibilityAggregated(boolean isVisible)
void
onVisibilityChanged(View changedView, int visibility)
void
onWindowFocusChanged(boolean hasWindowFocus)
void

This method is deprecated.

void
onWindowVisibilityChanged(int visibility)
boolean
overScrollBy(
    int deltaX,
    int deltaY,
    int scrollX,
    int scrollY,
    int scrollRangeX,
    int scrollRangeY,
    int maxOverScrollX,
    int maxOverScrollY,
    boolean isTouchEvent
)
boolean
performAccessibilityAction(int action, Bundle arguments)
boolean
boolean
performContextClick(float x, float y)
boolean
performHapticFeedback(int feedbackConstant)
boolean
ContentInfo
void
playSoundEffect(int soundConstant)
boolean
post(Runnable action)
boolean
postDelayed(Runnable action, long delayMillis)
void
void
postInvalidateDelayed(long delayMilliseconds)
void
void
void
postOnAnimationDelayed(Runnable action, long delayMillis)
void
void
boolean
void
void
void
void
void

This method is deprecated.

final boolean
void
void
boolean
final void
final T
<T extends View> requireViewById(int id)
void
static int
resolveSize(int size, int measureSpec)
static int
resolveSizeAndState(int size, int measureSpec, int childMeasuredState)
void
final void
saveAttributeDataForStyleable(
    Context context,
    int[] styleable,
    AttributeSet attrs,
    TypedArray t,
    int defStyleAttr,
    int defStyleRes
)
void
void
scheduleDrawable(Drawable who, Runnable what, long when)
void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
void
sendAccessibilityEvent(int eventType)
void
void
setAccessibilityDataSensitive(int accessibilityDataSensitive)
void
void
setAccessibilityHeading(boolean isHeading)
void
void
setAccessibilityPaneTitle(CharSequence accessibilityPaneTitle)
void
void
void
setActivated(boolean activated)
void
setAllowClickWhenDisabled(boolean clickableWhenDisabled)
void
void
void
setAlpha(float alpha)
void
void
void
setAutoHandwritingEnabled(boolean enabled)
void
setAutofillHints(String[] autofillHints)
void
void
setBackground(Drawable background)
void
setBackgroundColor(int color)
void

This method is deprecated.

void
void
void
void
final void
setBottom(int bottom)
void
setCameraDistance(float distance)
void
setClickable(boolean clickable)
void
setClipBounds(Rect clipBounds)
void
setClipToOutline(boolean clipToOutline)
void
void
setContentDescription(CharSequence contentDescription)
void
setContextClickable(boolean contextClickable)
void
setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled)
void

This method is deprecated.

void
setDrawingCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void
setElevation(float elevation)
void
setEnabled(boolean enabled)
void
setFadingEdgeLength(int length)
void
void
setFitsSystemWindows(boolean fitSystemWindows)
void
setFocusable(boolean focusable)
void
setFocusableInTouchMode(boolean focusableInTouchMode)
void
setFocusedByDefault(boolean isFocusedByDefault)
void
setForceDarkAllowed(boolean allow)
void
setForeground(Drawable foreground)
void
setForegroundGravity(int gravity)
void
void
void
void
setHandwritingBoundsOffsets(
    float offsetLeft,
    float offsetTop,
    float offsetRight,
    float offsetBottom
)
void
void
setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
void
setHasTransientState(boolean hasTransientState)
void
setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
void
setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
void
void
void
setHovered(boolean hovered)
void
setId(int id)
void
void
void
void
setIsCredential(boolean isCredential)
void
setIsHandwritingDelegate(boolean isHandwritingDelegate)
void
setKeepScreenOn(boolean keepScreenOn)
void
setKeyboardNavigationCluster(boolean isCluster)
void
setLabelFor(int id)
void
void
setLayerType(int layerType, Paint paint)
void
setLayoutDirection(int layoutDirection)
void
final void
setLeft(int left)
final void
setLeftTopRightBottom(int left, int top, int right, int bottom)
void
setLongClickable(boolean longClickable)
final void
setMeasuredDimension(int measuredWidth, int measuredHeight)
void
setMinimumHeight(int minHeight)
void
setMinimumWidth(int minWidth)
void
setNestedScrollingEnabled(boolean enabled)
void
setNextClusterForwardId(int nextClusterForwardId)
void
setNextFocusDownId(int nextFocusDownId)
void
setNextFocusForwardId(int nextFocusForwardId)
void
setNextFocusLeftId(int nextFocusLeftId)
void
setNextFocusRightId(int nextFocusRightId)
void
setNextFocusUpId(int nextFocusUpId)
void
void
void
void
void
void
void
void
void
void
void
void
setOnReceiveContentListener(
    String[] mimeTypes,
    OnReceiveContentListener listener
)
void
void

This method is deprecated.

void
void
void
void
void
setOverScrollMode(int overScrollMode)
void
setPadding(int left, int top, int right, int bottom)
void
setPaddingRelative(int start, int top, int end, int bottom)
void
setPivotX(float pivotX)
void
setPivotY(float pivotY)
void
final void
setPreferKeepClear(boolean preferKeepClear)
final void
void
setPressed(boolean pressed)
void
final void
setRevealOnFocusHint(boolean revealOnFocus)
final void
setRight(int right)
void
setRotation(float rotation)
void
setRotationX(float rotationX)
void
setRotationY(float rotationY)
void
setSaveEnabled(boolean enabled)
void
setSaveFromParentEnabled(boolean enabled)
void
setScaleX(float scaleX)
void
setScaleY(float scaleY)
void
setScreenReaderFocusable(boolean screenReaderFocusable)
void
setScrollBarDefaultDelayBeforeFade(
    int scrollBarDefaultDelayBeforeFade
)
void
setScrollBarFadeDuration(int scrollBarFadeDuration)
void
setScrollBarSize(int scrollBarSize)
void
setScrollBarStyle(int style)
final void
void
void
setScrollContainer(boolean isScrollContainer)
void
setScrollIndicators(int indicators)
void
setScrollX(int value)
void
setScrollY(int value)
void
setScrollbarFadingEnabled(boolean fadeScrollbars)
void
setSelected(boolean selected)
void
setSoundEffectsEnabled(boolean soundEffectsEnabled)
void
void
void
void
setSystemUiVisibility(int visibility)

This method is deprecated.

void
void
setTextAlignment(int textAlignment)
void
setTextDirection(int textDirection)
void
final void
setTop(int top)
void
void
setTransitionAlpha(float alpha)
final void
setTransitionName(String transitionName)
void
setTransitionVisibility(int visibility)
void
setTranslationX(float translationX)
void
setTranslationY(float translationY)
void
setTranslationZ(float translationZ)
void
setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)
void
setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
void
void
void
void
void
setVisibility(int visibility)
void
setWillNotCacheDrawing(boolean willNotCacheDrawing)

This method is deprecated.

void
setWillNotDraw(boolean willNotDraw)
void
setX(float x)
void
setY(float y)
void
setZ(float z)
boolean
ActionMode
void
final boolean
startDrag(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)

This method is deprecated.

final boolean
startDragAndDrop(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)
boolean
void
String
void
void
void
final void
boolean
boolean

This method is deprecated.

boolean
From android.view.ViewGroup
void
void
addExtraDataToAccessibilityNodeInfo(
    AccessibilityNodeInfo info,
    String extraDataKey,
    Bundle arguments
)
void
addFocusables(ArrayList<View> views, int direction, int focusableMode)
void
boolean
void
void
addView(View child)
boolean
addViewInLayout(View child, int index, ViewGroup.LayoutParams params)
void
attachLayoutAnimationParameters(
    View child,
    ViewGroup.LayoutParams params,
    int index,
    int count
)
void
attachViewToParent(View child, int index, ViewGroup.LayoutParams params)
void
boolean
void
void
childHasTransientStateChanged(
    View child,
    boolean childHasTransientState
)
void
void
void
void
void
debug(int depth)
void
void
void
detachViewsFromParent(int start, int count)
WindowInsets
boolean
void
void
dispatchCreateViewTranslationRequest(
    Map<AutofillId, long[]> viewIds,
    int[] supportedFormats,
    TranslationCapability capability,
    List<ViewTranslationRequest> requests
)
void
boolean
void
void
dispatchDrawableHotspotChanged(float x, float y)
void
void
boolean
boolean
boolean
boolean
boolean
boolean
void
dispatchPointerCaptureChanged(boolean hasCapture)
void
void
void
void
void
dispatchScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
dispatchSetActivated(boolean activated)
void
dispatchSetPressed(boolean pressed)
void
dispatchSetSelected(boolean selected)
void
void

This method is deprecated.

void
boolean
boolean
boolean
dispatchUnhandledMove(View focused, int direction)
void
dispatchVisibilityChanged(View changedView, int visibility)
void
dispatchWindowFocusChanged(boolean hasFocus)
void
void
WindowInsets
WindowInsetsAnimation.Bounds
void

This method is deprecated.

void
void
void
View
OnBackInvokedDispatcher
void
findViewsWithText(
    ArrayList<View> outViews,
    CharSequence text,
    int flags
)
View
focusSearch(View focused, int direction)
void
boolean
CharSequence
View
getChildAt(int index)
int
int
getChildDrawingOrder(int childCount, int drawingPosition)
static int
getChildMeasureSpec(int spec, int padding, int childDimension)
boolean
boolean
getChildVisibleRect(View child, Rect r, Point offset)
boolean
boolean
int
View
LayoutAnimationController
Animation.AnimationListener
int
LayoutTransition
int
ViewGroupOverlay
int

This method is deprecated.

boolean
boolean
boolean
int
final void
invalidateChild(View child, Rect dirty)

This method is deprecated.

ViewParent
invalidateChildInParent(int[] location, Rect dirty)

This method is deprecated.

boolean

This method is deprecated.

boolean

This method is deprecated.

boolean
boolean

This method is deprecated.

boolean
boolean
boolean
void
final void
layout(int l, int t, int r, int b)
void
measureChild(
    View child,
    int parentWidthMeasureSpec,
    int parentHeightMeasureSpec
)
void
measureChildWithMargins(
    View child,
    int parentWidthMeasureSpec,
    int widthUsed,
    int parentHeightMeasureSpec,
    int heightUsed
)
void
measureChildren(int widthMeasureSpec, int heightMeasureSpec)
void
notifySubtreeAccessibilityStateChanged(
    View child,
    View source,
    int changeType
)
final void
final void
int[]
onCreateDrawableState(int extraSpace)
void
boolean
boolean
onNestedFling(
    View target,
    float velocityX,
    float velocityY,
    boolean consumed
)
boolean
onNestedPreFling(View target, float velocityX, float velocityY)
boolean
onNestedPrePerformAccessibilityAction(
    View target,
    int action,
    Bundle args
)
void
onNestedPreScroll(View target, int dx, int dy, int[] consumed)
void
onNestedScroll(
    View target,
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed
)
void
onNestedScrollAccepted(View child, View target, int axes)
boolean
onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
boolean
PointerIcon
onResolvePointerIcon(MotionEvent event, int pointerIndex)
boolean
onStartNestedScroll(View child, View target, int nestedScrollAxes)
void
void
void
void
void
void
void
removeDetachedView(View child, boolean animate)
void
removeViewAt(int index)
void
void
removeViews(int start, int count)
void
removeViewsInLayout(int start, int count)
boolean
requestChildRectangleOnScreen(
    View child,
    Rect rectangle,
    boolean immediate
)
void
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
boolean
requestFocus(int direction, Rect previouslyFocusedRect)
boolean
void
boolean
void
void
setAddStatesFromChildren(boolean addsStates)
void

This method is deprecated.

void
setAnimationCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void

This method is deprecated.

void
setClipChildren(boolean clipChildren)
void
setClipToPadding(boolean clipToPadding)
void
setDescendantFocusability(int focusability)
void
void
void
setLayoutMode(int layoutMode)
void
void
void
void
setPersistentDrawingCache(int drawingCacheToKeep)

This method is deprecated.

void
void
setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus)
void
setTransitionGroup(boolean isTransitionGroup)
void
boolean
boolean
ActionMode
startActionModeForChild(
    View originalView,
    ActionMode.Callback callback
)
void
void
void
suppressLayout(boolean suppress)
void

Constants

LOCK_MODE_LOCKED

Added in 1.2.0
public static final int LOCK_MODE_LOCKED = 3

The user cannot swipe between list and detail panes, though the app can open or close the detail pane programmatically.

LOCK_MODE_LOCKED_CLOSED

Added in 1.2.0
public static final int LOCK_MODE_LOCKED_CLOSED = 2

The detail pane is locked in a closed position. The user cannot swipe to open the detail pane, but the app can open the detail pane programmatically.

LOCK_MODE_LOCKED_OPEN

Added in 1.2.0
public static final int LOCK_MODE_LOCKED_OPEN = 1

The detail pane is locked in an open position. The user cannot swipe to close the detail pane, but the app can close the detail pane programmatically.

LOCK_MODE_UNLOCKED

Added in 1.2.0
public static final int LOCK_MODE_UNLOCKED = 0

User can freely swipe between list and detail panes.

Public constructors

SlidingPaneLayout

Added in 1.1.0
public SlidingPaneLayout(@NonNull Context context)

SlidingPaneLayout

Added in 1.1.0
public SlidingPaneLayout(@NonNull Context context, @Nullable AttributeSet attrs)

SlidingPaneLayout

Added in 1.1.0
public SlidingPaneLayout(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyle
)

Public methods

addPanelSlideListener

Added in 1.2.0
public void addPanelSlideListener(
    @NonNull SlidingPaneLayout.PanelSlideListener listener
)

Adds the specified listener to the list of listeners that will be notified of panel slide events.

Parameters
@NonNull SlidingPaneLayout.PanelSlideListener listener

Listener to notify when panel slide events occur.

addView

public void addView(
    @NonNull View child,
    int index,
    @Nullable ViewGroup.LayoutParams params
)

canSlide

Added in 1.1.0
Deprecated in 1.1.0
public boolean canSlide()
Returns
boolean

true if content in this layout can be slid open and closed

close

Added in 1.1.0
public void close()

Close the detail view if it is currently slideable. If first layout has already completed this will animate.

closePane

Added in 1.1.0
public boolean closePane()

Close the detail view if it is currently slideable. If first layout has already completed this will animate.

Returns
boolean

true if the pane was slideable and is now closed/in the process of closing

computeScroll

public void computeScroll()

draw

public void draw(Canvas c)

generateLayoutParams

public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)

getCoveredFadeColor

Added in 1.1.0
Deprecated in 1.2.0
public @ColorInt int getCoveredFadeColor()
Returns
@ColorInt int

The ARGB-packed color value used to fade the fixed pane

getLockMode

Added in 1.2.0
public final int getLockMode()

Get the lock mode used to control over the swipe behavior.

See also
setLockMode

getParallaxDistance

Added in 1.1.0
public @Px int getParallaxDistance()
Returns
@Px int

The distance the lower pane will parallax by when the upper pane is fully closed.

getSliderFadeColor

Added in 1.1.0
Deprecated in 1.2.0
public @ColorInt int getSliderFadeColor()
Returns
@ColorInt int

The ARGB-packed color value used to fade the sliding pane

isOpen

Added in 1.1.0
public boolean isOpen()

Check if the detail view is completely open. It can be open either because the slider itself is open revealing the detail view, or if all content fits without sliding.

Returns
boolean

true if the detail view is completely open

isSlideable

Added in 1.1.0
public boolean isSlideable()

Check if both the list and detail view panes in this layout can fully fit side-by-side. If not, the content pane has the capability to slide back and forth. Note that the lock mode is not taken into account in this method. This method is typically used to determine whether the layout is showing two-pane or single-pane.

Returns
boolean

true if both panes cannot fit side-by-side, and detail pane in this layout has the capability to slide back and forth.

onInterceptTouchEvent

public boolean onInterceptTouchEvent(MotionEvent ev)

onTouchEvent

public boolean onTouchEvent(MotionEvent ev)

open

Added in 1.1.0
public void open()

Open the detail view if it is currently slideable. If first layout has already completed this will animate.

openPane

Added in 1.1.0
public boolean openPane()

Open the detail view if it is currently slideable. If first layout has already completed this will animate.

Returns
boolean

true if the pane was slideable and is now open/in the process of opening

removePanelSlideListener

Added in 1.2.0
public void removePanelSlideListener(
    @NonNull SlidingPaneLayout.PanelSlideListener listener
)

Removes the specified listener from the list of listeners that will be notified of panel slide events.

Parameters
@NonNull SlidingPaneLayout.PanelSlideListener listener

Listener to remove from being notified of panel slide events

removeView

public void removeView(@NonNull View view)

requestChildFocus

public void requestChildFocus(View child, View focused)

setCoveredFadeColor

Added in 1.1.0
Deprecated in 1.2.0
public void setCoveredFadeColor(@ColorInt int color)

Set the color used to fade the pane covered by the sliding pane out when the pane will become fully covered in the closed state.

Parameters
@ColorInt int color

An ARGB-packed color value

setLockMode

Added in 1.2.0
public final void setLockMode(int lockMode)

Set the lock mode that controls how the user can swipe between the panes.

Parameters
int lockMode

The new lock mode for the detail pane.

setPanelSlideListener

Added in 1.1.0
Deprecated in 1.2.0
public void setPanelSlideListener(
    @Nullable SlidingPaneLayout.PanelSlideListener listener
)

Set a listener to be notified of panel slide events. Note that this method is deprecated and you should use addPanelSlideListener to add a listener and removePanelSlideListener to remove a registered listener.

Parameters
@Nullable SlidingPaneLayout.PanelSlideListener listener

Listener to notify when drawer events occur

setParallaxDistance

Added in 1.1.0
public void setParallaxDistance(@Px int parallaxBy)

Set a distance to parallax the lower pane by when the upper pane is in its fully closed state. The lower pane will scroll between this position and its fully open state.

Parameters
@Px int parallaxBy

Distance to parallax by in pixels

setShadowDrawable

Added in 1.1.0
Deprecated in 1.1.0
public void setShadowDrawable(Drawable d)
Parameters
Drawable d

drawable to use as a shadow

setShadowDrawableLeft

Added in 1.1.0
public void setShadowDrawableLeft(@Nullable Drawable d)

Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.

Parameters
@Nullable Drawable d

drawable to use as a shadow

setShadowDrawableRight

Added in 1.1.0
public void setShadowDrawableRight(@Nullable Drawable d)

Set a drawable to use as a shadow cast by the left pane onto the right pane during opening/closing to support right to left language.

Parameters
@Nullable Drawable d

drawable to use as a shadow

setShadowResource

Added in 1.1.0
Deprecated in 1.1.0
public void setShadowResource(@DrawableRes int resId)

Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.

Parameters
@DrawableRes int resId

Resource ID of a drawable to use

setShadowResourceLeft

Added in 1.1.0
public void setShadowResourceLeft(int resId)

Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.

Parameters
int resId

Resource ID of a drawable to use

setShadowResourceRight

Added in 1.1.0
public void setShadowResourceRight(int resId)

Set a drawable to use as a shadow cast by the left pane onto the right pane during opening/closing to support right to left language.

Parameters
int resId

Resource ID of a drawable to use

setSliderFadeColor

Added in 1.1.0
Deprecated in 1.2.0
public void setSliderFadeColor(@ColorInt int color)

Set the color used to fade the sliding pane out when it is slid most of the way offscreen.

Parameters
@ColorInt int color

An ARGB-packed color value

smoothSlideClosed

Added in 1.1.0
Deprecated in 1.1.0
public void smoothSlideClosed()

smoothSlideOpen

Added in 1.1.0
Deprecated in 1.1.0
public void smoothSlideOpen()

Protected methods

canScroll

Added in 1.1.0
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y)

Tests scrollability within child views of v given a delta of dx.

Parameters
View v

View to test for horizontal scrollability

boolean checkV

Whether the view v passed should itself be checked for scrollability (true), or just its children (false).

int dx

Delta scrolled in pixels

int x

X coordinate of the active touch point

int y

Y coordinate of the active touch point

Returns
boolean

true if child views of v can be scrolled by delta of dx.

checkLayoutParams

protected boolean checkLayoutParams(ViewGroup.LayoutParams p)

drawChild

protected boolean drawChild(Canvas canvas, View child, long drawingTime)

generateDefaultLayoutParams

protected ViewGroup.LayoutParams generateDefaultLayoutParams()

onAttachedToWindow

protected void onAttachedToWindow()

onDetachedFromWindow

protected void onDetachedFromWindow()

onLayout

protected void onLayout(boolean changed, int l, int t, int r, int b)

onMeasure

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

onRestoreInstanceState

protected void onRestoreInstanceState(Parcelable state)

onSaveInstanceState

protected Parcelable onSaveInstanceState()

onSizeChanged

protected void onSizeChanged(int w, int h, int oldw, int oldh)