SlidingPaneLayout

open class SlidingPaneLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) : ViewGroup, Openable(source)

(SESL variant) 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.

Constructors

Link copied to clipboard
constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
Link copied to clipboard

Listener for monitoring events about sliding panes.

Link copied to clipboard
Link copied to clipboard

No-op stubs for PanelSlideListener. If you only want to implement a subset of the listener methods you can extend this instead of implement the full interface.

Link copied to clipboard

Listener to whether the SlidingPaneLayout is slideable or is a fixed width.

Link copied to clipboard

Policy implementation for user resizing. See USER_RESIZE_RELAYOUT_WHEN_COMPLETE or USER_RESIZE_RELAYOUT_WHEN_MOVED for default implementations, or this interface may be implemented externally to apply additional behaviors such as snapping to predefined breakpoints.

Properties

Link copied to clipboard

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. This value is no longer used.

Link copied to clipboard
Link copied to clipboard

true if the user is currently dragging the user resizing divider

Link copied to clipboard

When set, if sufficient space is not available to present child panes side by side while respecting the child pane's LayoutParams.width or minimum width, the SlidingPaneLayout may allow the child panes to overlap. When child panes overlap lockMode determines whether the user can drag the top pane to one side to make the lower pane available for viewing or interaction.

Link copied to clipboard

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.

Link copied to clipboard

true if user resizing of side-by-side panes is currently available. This means that:

Link copied to clipboard

Set to true to enable user resizing of side by side panes through gestures or other inputs. This may also be set from the isUserResizingEnabled XML attribute during view inflation. A divider drawable must be provided; see setUserResizingDividerDrawable and isUserResizable.

Link copied to clipboard

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

Link copied to clipboard
@get:Px
open var parallaxDistance: Int

Distance to parallax the lower pane by when the upper pane is in its fully closed state, in pixels. The lower pane will scroll between this position and its fully open state.

Link copied to clipboard

The ARGB-packed color value used to fade the sliding pane. This property is no longer used.

Link copied to clipboard

Position of the division between split panes when isSlideable is false. When the value is < 0 it should be one of the SPLIT_DIVIDER_POSITION_* constants, e.g. SPLIT_DIVIDER_POSITION_AUTO. When the value is >= 0 it represents a value in pixels between 0 and getWidth. The default value is SPLIT_DIVIDER_POSITION_AUTO.

Link copied to clipboard

The center position in the X dimension of the visual divider indicator between panes. If isUserResizable would return false this property will return < 0. If the user is actively dragging the divider this will reflect its current drag position. If not, it will reflect splitDividerPosition if splitDividerPosition would return >= 0, or the automatically determined divider position if splitDividerPosition would return SPLIT_DIVIDER_POSITION_AUTO.

Functions

Link copied to clipboard

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

Link copied to clipboard

Adds the specified listener to the list of listeners that will be notified of sliding state events.

Link copied to clipboard
open override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams?)
Link copied to clipboard
open fun canSlide(): Boolean
Link copied to clipboard
open override fun close()

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

Link copied to clipboard
open fun closePane(): Boolean

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

Link copied to clipboard
open override fun computeScroll()
Link copied to clipboard
open override fun draw(c: Canvas)
Link copied to clipboard
open override fun drawableHotspotChanged(x: Float, y: Float)
Link copied to clipboard
Link copied to clipboard

Retrieves the current status of the single panel.

Link copied to clipboard

How far in pixels the slideable panel may move.

Link copied to clipboard
open override fun isOpen(): Boolean

Check if the drawer/list view is completely open. It can be open either because the slider itself is open revealing the drawer/list view, or if all content visible without sliding.

Link copied to clipboard
open override fun jumpDrawablesToCurrentState()
Link copied to clipboard
open override fun onInterceptTouchEvent(ev: MotionEvent): Boolean
Link copied to clipboard
open override fun onTouchEvent(ev: MotionEvent): Boolean
Link copied to clipboard
open override fun open()

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

Link copied to clipboard
open fun openPane(): Boolean

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

Link copied to clipboard

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

Link copied to clipboard

Removes the specified listener from the list of listeners that will be notified of sliding state events.

Link copied to clipboard
open override fun removeView(view: View)
Link copied to clipboard
open override fun requestChildFocus(child: View?, focused: View?)
Link copied to clipboard
open fun resizeSlideableView(offset: Float)
Link copied to clipboard
fun seslClosePane(animate: Boolean)

Close the drawer/list pane

Link copied to clipboard

Checks if the user can swipe the drawer pane.

Link copied to clipboard

If true, the views in details pane won't be resized and will just slide out when the drawer pane is opened.

Link copied to clipboard

Get if rounded corner is enabled on the drawer pane

Link copied to clipboard

This value represents the area where a user can drag the sliding pane.

Link copied to clipboard

Retrieves the current sliding state.

Link copied to clipboard
fun seslOpenPane(animate: Boolean)

Open the drawer/list pane

Link copied to clipboard

Override the maximum width of contents in the details pane.

Link copied to clipboard
Link copied to clipboard

Sets the bottom margin for the drawer pane.

Link copied to clipboard

Sets the top margin of the drawer.

Link copied to clipboard
fun seslSetLock(isLock: Boolean)

Sets the lock state of the drawer pane.

Link copied to clipboard
fun seslSetResizeChild(vararg view: View?)

Specify the child view(s) of details pane which width are to be resized to fit them inside even when drawer pane is fully opened. Applies only when seslGetResizeOff is false.

Link copied to clipboard
fun seslSetResizeOff(turnOffResize: Boolean)

Disables the auto resizing the views width inside the details pane. The views will just slide out when the drawer pane is expanded.

Link copied to clipboard

Set custom rounded corner color to the drawer pane

Link copied to clipboard

Disable rounded corner on the drawer pane

Link copied to clipboard
fun seslSetRoundedCornerOn(@Px radius: Int? = null)

Enable rounded corner on the drawer pane

Link copied to clipboard

Set a View.OnClickListener that will be invoked if the user clicks/taps on the resizing divider. The divider is only available to be clicked if isUserResizable.

Link copied to clipboard

Currently, SESL6 version still applies overhangSize with hard-coded value in setting the width of the fixed/drawer panel. However, overhangSize is already deprecated and removed in the latest version of jetpack SlidingPaneLayout version. This method is intended to workaround this.

Link copied to clipboard

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.

Link copied to clipboard
open fun setShadowDrawable(drawable: Drawable?)

Set a drawable to use as a shadow.

Link copied to clipboard
open fun setShadowDrawableLeft(drawable: Drawable?)

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

Link copied to clipboard
open fun setShadowDrawableRight(drawable: Drawable?)

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.

Link copied to clipboard
open fun setShadowResource(@DrawableRes resId: Int)

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

Link copied to clipboard

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

Link copied to clipboard

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.

Link copied to clipboard
fun setSinglePanel(isSinglePanel: Boolean)

Sets whether the layout should operate in single panel mode.

Link copied to clipboard

Configure the UserResizeBehavior that will be used to adjust the splitDividerPosition when isUserResizable and the user drags the divider from side to side.

Link copied to clipboard

Set a Drawable to display when isUserResizingEnabled is true and multiple panes are visible without overlapping. This forms the visual touch target for dragging. This may also be set from the userResizingDividerDrawable XML attribute during view inflation.

Set a Drawable by resource id to display when isUserResizingEnabled is true and multiple panes are visible without overlapping. This forms the visual touch target for dragging. This may also be set from the userResizingDividerDrawable XML attribute during view inflation.

Link copied to clipboard
Link copied to clipboard
open fun smoothSlideOpen()