DividerAttributes.DraggableDividerAttributes.Builder


@RequiresWindowSdkExtension(version = 6)
public final class DividerAttributes.DraggableDividerAttributes.Builder


The DraggableDividerAttributes builder.

Summary

Public constructors

creates a new DraggableDividerAttributes.Builder

The DraggableDividerAttributes builder constructor initialized by an existing DraggableDividerAttributes.

Public methods

final @NonNull DividerAttributes.DraggableDividerAttributes

Builds a DividerAttributes instance.

final @NonNull DividerAttributes.DraggableDividerAttributes.Builder
@RequiresWindowSdkExtension(version = 6)
setColor(@ColorInt int color)

Sets the color of the divider.

final @NonNull DividerAttributes.DraggableDividerAttributes.Builder

Sets the drag range of the divider in terms of the split ratio of the primary container.

final @NonNull DividerAttributes.DraggableDividerAttributes.Builder

Sets whether dragging to full screen is allowed.

final @NonNull DividerAttributes.DraggableDividerAttributes.Builder
@RequiresWindowSdkExtension(version = 6)
setWidthDp(@IntRange(from = -1) int widthDp)

Sets the divider width.

Public constructors

Builder

Added in 1.4.0
public Builder()

creates a new DraggableDividerAttributes.Builder

Builder

Added in 1.4.0
@RequiresWindowSdkExtension(version = 6)
public Builder(@NonNull DividerAttributes.DraggableDividerAttributes original)

The DraggableDividerAttributes builder constructor initialized by an existing DraggableDividerAttributes.

Parameters
@NonNull DividerAttributes.DraggableDividerAttributes original

the original DraggableDividerAttributes to initialize the Builder

Public methods

build

Added in 1.4.0
@RequiresWindowSdkExtension(version = 6)
public final @NonNull DividerAttributes.DraggableDividerAttributes build()

Builds a DividerAttributes instance.

setColor

Added in 1.4.0
@RequiresWindowSdkExtension(version = 6)
public final @NonNull DividerAttributes.DraggableDividerAttributes.Builder setColor(@ColorInt int color)

Sets the color of the divider. If not set, the default color Color.BLACK is used.

Throws
kotlin.IllegalArgumentException

if the provided value is invalid.

setDragRange

Added in 1.4.0
@RequiresWindowSdkExtension(version = 6)
public final @NonNull DividerAttributes.DraggableDividerAttributes.Builder setDragRange(@NonNull DividerAttributes.DragRange dragRange)

Sets the drag range of the divider in terms of the split ratio of the primary container. It defaults to DragRange.DRAG_RANGE_SYSTEM_DEFAULT, which means the system will choose a default value based on the display size and form factor.

When the user drags the divider beyond this range, the system will choose to either fully expand the container or move the divider back into the range.

Parameters
@NonNull DividerAttributes.DragRange dragRange

the DragRange for the draggable divider.

setDraggingToFullscreenAllowed

Added in 1.5.0-alpha02
@RequiresWindowSdkExtension(version = 7)
public final @NonNull DividerAttributes.DraggableDividerAttributes.Builder setDraggingToFullscreenAllowed(boolean allowed)

Sets whether dragging to full screen is allowed.

If true, the user is allowed to drag beyond the specified range temporarily. When dragging is finished, if the dragging position is below the DragRange.SplitRatioDragRange.minRatio or the default min ratio in DragRange.DRAG_RANGE_SYSTEM_DEFAULT, the system will choose to either fully expand the secondary container or move the divider back to the range limit; if the dragging position is above the DragRange.SplitRatioDragRange.maxRatio or the default max ratio in DragRange.DRAG_RANGE_SYSTEM_DEFAULT, the system will choose to either fully expand the primary container or move the divider back to the range limit.

When the primary container is fully expanded, the secondary container is dismissed. When the secondary container is fully expanded, the primary container is hidden behind the secondary container, and the drag handle is displayed on the edge to allow the user to drag and bring back the primary container.

Default to false.

This is only supported on devices with Window SDK extensions version 7 and above. For devices with Window SDK extensions below version 7, dragging to fullscreen is always disabled.

setWidthDp

Added in 1.4.0
@RequiresWindowSdkExtension(version = 6)
public final @NonNull DividerAttributes.DraggableDividerAttributes.Builder setWidthDp(@IntRange(from = -1) int widthDp)

Sets the divider width. It defaults to WIDTH_SYSTEM_DEFAULT, which means the system will choose a default value based on the display size and form factor.

When 0dp is used for a draggable divider, the drag handle is rendered without a divider line.

Note: a known compatibility issue causes incorrect rendering of 0-width divider in extensions v7. In this case, the divider width is set to 1dp as a mitigation.

Throws
kotlin.IllegalArgumentException

if the provided value is invalid.