Skip to content

SplitView

Since 2.2.1

SplitView is a two-pane container whose divider can be dragged to resize the panes. Two concrete variants are registered:

  • split-view-horizontal — left/right split with a vertical divider.
  • split-view-vertical — top/bottom split with a horizontal divider.

The divider position is expressed as a percentage (0–100 %). Dragging the border adjusts it in real time.

INFO

Everything documented on UIElement (layout, styles, events, data bindings, etc.) applies here too.


Usage

java
var split = new SplitView.Horizontal();
split.left(leftContent);
split.right(rightContent);
split.setPercentage(30f);
parent.addChild(split);

var vsplit = new SplitView.Vertical();
vsplit.top(topContent);
vsplit.bottom(bottomContent);
parent.addChild(vsplit);

XML

xml
<split-view-horizontal percentage="30">
    <first>
        <!-- left pane content -->
    </first>
    <second>
        <!-- right pane content -->
    </second>
</split-view-horizontal>

<split-view-vertical percentage="50">
    <first>
        <!-- top pane content -->
    </first>
    <second>
        <!-- bottom pane content -->
    </second>
</split-view-vertical>
XML AttributeTypeDescription
percentagefloatInitial divider position (0–100). Default: 50.

The &lt;first&gt; and &lt;second&gt; child elements configure the two panes.


Internal Structure

FieldCSS classDescription
first.__split_view_first__First pane (left for horizontal, top for vertical).
second.__split_view_second__Second pane (right for horizontal, bottom for vertical).

Fields

NameTypeAccessDescription
firstUIElementpublic finalFirst pane.
secondUIElementpublic finalSecond pane.
borderSizefloatgetter/setterWidth of the draggable border hit area. Default: 2.
minPercentagefloatgetter/setterMinimum allowed divider percentage. Default: 5.
maxPercentagefloatgetter/setterMaximum allowed divider percentage. Default: 95.

Methods

Common

MethodReturnsDescription
first(UIElement)SplitViewReplaces the content of the first pane.
second(UIElement)SplitViewReplaces the content of the second pane.
setPercentage(float)SplitViewSets the divider position, clamped to [minPercentage, maxPercentage].
getPercentage()floatReturns the current divider position as a percentage.
setBorderSize(float)SplitViewSets the draggable border width.
setMinPercentage(float)SplitViewSets the lower bound for the divider.
setMaxPercentage(float)SplitViewSets the upper bound for the divider.

Horizontal-only

MethodReturnsDescription
left(UIElement)HorizontalAlias for first().
right(UIElement)HorizontalAlias for second().

Vertical-only

MethodReturnsDescription
top(UIElement)VerticalAlias for first().
bottom(UIElement)VerticalAlias for second().

Released under the MIT License.