B4X Store

ELEVATEUI · B4A · XUI

UICollapse

Hide secondary information until the user needs to expand it.

78 modules 1,780 APIs

Effects & interface utilities

What it solves

Hide secondary information until the user needs to expand it.

Animated conceptual demonstration, not an exact Android control screenshot.

12 methods0 Designer1 events

When to use this module

Use the effect after a meaningful interaction and ensure it does not replace an accessible state or confirmation.

Before integrating, examine its methods, events and Designer options.

B4A integration examples

Tutorials are based on existing project examples or audited APIs. Check each example’s prerequisites; B4A compilation is not claimed.

Expandable settings section with a live action and ExpandedChanged event
Reviewed integration tutorial ElevateUI(6).b4xlib: UICollapse.bas + Snippets/Add UICollapse.txt + UIButton.bas Not B4A-compiled

B4A Activity; enable XUI and ElevateUI. UICollapse does not have AddToParent: create a B4XView ContentPanel, add its child controls, then pass it to CreateCollapse. The class calls ExpandedChanged(Expanded As Boolean).

' Activity Main: UICollapse + UIButton
' The collapsible panel holds a real ElevateUI action button.
Sub Process_Globals
End Sub

Sub Globals
    Private xui As XUI
    Private settingsCollapse As UICollapse
    Private contentPanel As B4XView
    Private btnApply As UIButton
    Private lblStatus As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.Color = 0xFFF1F5F9

    ' The content panel defines the expanded body height.
    contentPanel = xui.CreatePanel("")
    contentPanel.SetLayoutAnimated(0, 0, 0, Activity.Width - 36dip, 118dip)
    contentPanel.Color = Colors.White

    lblStatus.Initialize("")
    lblStatus.Text = "Notifications: enabled"
    lblStatus.TextColor = 0xFF334155
    contentPanel.AddView(lblStatus, 8dip, 8dip, contentPanel.Width - 16dip, 30dip)

    btnApply.Initialize(Me, "btnApply")
    btnApply.AddToParent(contentPanel, 8dip, 48dip, _
        contentPanel.Width - 16dip, 48dip, _
        1, 15, "Apply settings", Colors.White, _
        0xFF35B998, 0xFF1C8573, "LEFT_RIGHT", 10dip)

    settingsCollapse.Initialize(Me, "Settings")
    settingsCollapse.ExpandAnimationDuration = 220
    settingsCollapse.CollapseAnimationDuration = 150
    settingsCollapse.CreateCollapse(Activity, 12dip, 30dip, _
        Activity.Width - 24dip, "Notification settings", contentPanel)
    settingsCollapse.SetLeftIcon(Chr(0xF013), _
        xui.CreateFontAwesome(16), 0xFF475569)
    settingsCollapse.SetVariantAccent(0xFF1E3A5F, Colors.White)
    settingsCollapse.Expand
End Sub

Private Sub btnApply_Click
    lblStatus.Text = "Settings applied"
    settingsCollapse.Collapse
    ToastMessageShow("Settings updated.", False)
End Sub

Private Sub Settings_ExpandedChanged(Expanded As Boolean)
    Log("Notification settings expanded: " & Expanded)
    If Expanded Then
        lblStatus.Text = "Choose your preferences"
    End If
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause(UserClosed As Boolean)
End Sub

Public methods reference

12 audited signatures

Public Sub Initialize(Callback As Object, EventName As String)

Prepare the instance before its other methods.

Callback As ObjectEventName As String
Public Sub CreateCollapse(Parent As B4XView, Left As Int, Top As Int, Width As Int, Title As String, ContentPanel As B4XView)

Use CreateCollapse for its named operation; follow its exact signature.

Parent As B4XViewLeft As IntTop As IntWidth As IntTitle As StringContentPanel As B4XView
Public Sub SetLeftIcon(IconChar As String, IconFont As B4XFont, LeftIconColor As Int)

Use SetLeftIcon for its named operation; follow its exact signature.

Original catalog note: Adds an optional left icon alongside title

IconChar As StringIconFont As B4XFontLeftIconColor As Int
Public Sub SetVariantPrimary(BgColor As Int, TextColor As Int)

Use SetVariantPrimary for its named operation; follow its exact signature.

Original catalog note: Set filled Primary theme variant

BgColor As IntTextColor As Int
Public Sub SetVariantAccent(BgColor As Int, TextColor As Int)

Use SetVariantAccent for its named operation; follow its exact signature.

Original catalog note: Set Accent theme variant

BgColor As IntTextColor As Int
Public Sub ApplyStyles

Use ApplyStyles for its named operation; follow its exact signature.

Public Sub Toggle

Use Toggle for its named operation; follow its exact signature.

Public Sub Expand

Use Expand for its named operation; follow its exact signature.

Public Sub Collapse

Use Collapse for its named operation; follow its exact signature.

Public Sub SetExpanded(Expanded As Boolean)

Use SetExpanded for its named operation; follow its exact signature.

Expanded As Boolean
Public Sub GetExpanded As Boolean

Use GetExpanded for its named operation; follow its exact signature.

Returns: Boolean

Public Sub SetTitle(Title As String)

Use SetTitle for its named operation; follow its exact signature.

Title As String

Designer · 0

No custom Designer properties were found in the audited API.

Public events and how to implement them · 1

Initialize with Me and the event prefix Demo, then add the following handler to your B4A module. Names and arguments come from the library declaration.

ExpandedChanged(Expanded As Boolean)

Raised when the content opens or closes; Expanded indicates the new state.

B4A handler signature with Demo prefix

Private Sub Demo_ExpandedChanged(Expanded As Boolean)
    Log("ExpandedChanged")
End Sub

For code-created controls use Initialize(Me, "Demo") when that signature exists; for Designer controls set the event name there. Replace Demo with the actual prefix.

Public fields, constants and types

Public HeaderBackgroundColor As Int = 0xFFFFFFFFPublic HeaderTextColor As Int = 0xFF1E293BPublic BodyBackgroundColor As Int = 0xFFFFFFFFPublic BodyTextColor As Int = 0xFF475569Public BorderColor As Int = 0xFFCBD5E1Public BorderWidth As Int = 1dipPublic CornerRadius As Float = 10dipPublic ExpandIconPosition As String = "RIGHT" ' "RIGHT" or "LEFT"Public ExpandIconStyle As String = "ARROW" ' "ARROW" or "PLUS_MINUS"Public IconColor As Int = 0xFF475569Public BodyPadding As Int = 8dip ' Padding inside body so added panel does not overlap container bordersPublic ExpandAnimationDuration As Int = 200 ' Animation ms when openingPublic CollapseAnimationDuration As Int = 0 ' 0ms = no animation when closing
Source: ElevateUI public API catalog; tutorials cross-checked against ElevateUI(6).b4xlib. Visualizations are illustrative; sample code requires B4A compilation.