SlidingPaneLayout
(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.
Types
Listener for monitoring events about sliding panes.
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.
Listener to whether the SlidingPaneLayout is slideable or is a fixed width.
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
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.
true
if child views are clipped to visualDividerPosition.
true
if the user is currently dragging the user resizing divider
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.
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.
true
if user resizing of side-by-side panes is currently available. This means that:
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.
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.
The ARGB-packed color value used to fade the sliding pane. This property is no longer used.
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.
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
Adds the specified listener to the list of listeners that will be notified of panel slide events.
Adds the specified listener to the list of listeners that will be notified of sliding state events.
Retrieves the current status of the single panel.
How far in pixels the slideable panel may move.
Removes the specified listener from the list of listeners that will be notified of panel slide events.
Removes the specified listener from the list of listeners that will be notified of sliding state events.
Close the drawer/list pane
Checks if the user can swipe the drawer pane.
If true, the views in details pane won't be resized and will just slide out when the drawer pane is opened.
Get if rounded corner is enabled on the drawer pane
This value represents the area where a user can drag the sliding pane.
Retrieves the current sliding state.
Open the drawer/list pane
Override the maximum width of contents in the details pane.
Sets the bottom margin for the drawer pane.
Sets the top margin of the drawer.
Sets the lock state of the drawer pane.
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.
Disables the auto resizing the views width inside the details pane. The views will just slide out when the drawer pane is expanded.
Set custom rounded corner color to the drawer pane
Disable rounded corner on the drawer pane
Enable rounded corner on the drawer pane
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.
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.
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.
Set a drawable to use as a shadow.
Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.
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.
Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.
Set a drawable to use as a shadow cast by the right pane onto the left pane during opening/closing.
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.
Sets whether the layout should operate in single panel mode.
Configure the UserResizeBehavior that will be used to adjust the splitDividerPosition when isUserResizable and the user drags the divider from side to side.
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.