Customization¶
Balloon 1.x (View)
This page documents Balloon 1.7.6, the last release of the View based library.
For the current version see the Balloon 2.0.0 documentation and the
Migration guide.
This guide covers various customization options for Balloon tooltips.
Background¶
Background Color¶
Balloon.Builder(context)
.setBackgroundColor(Color.BLACK)
.setBackgroundColorResource(R.color.skyBlue)
Corner Radius¶
Balloon.Builder(context)
.setCornerRadius(8f)
Alpha (Transparency)¶
Balloon.Builder(context)
.setAlpha(0.9f) // 0.0 to 1.0
Stroke (Border)¶
Add a stroke (border) to the Balloon container and arrow:
Balloon.Builder(context)
.setBalloonStroke(
color = Color.WHITE,
thickness = 4f
)
Elevation and Shadow¶
Balloon.Builder(context)
.setElevation(6f)
Focus and Dismiss Behavior¶
Focusable¶
Balloon.Builder(context)
.setFocusable(true) // gains focus when shown
Dismiss When Clicked¶
Balloon.Builder(context)
.setDismissWhenClicked(true) // dismiss when Balloon is clicked
Dismiss When Touched Outside¶
Balloon.Builder(context)
.setDismissWhenTouchOutside(true) // dismiss when touching outside
Dismiss When Shown Again¶
Balloon.Builder(context)
.setDismissWhenShowAgain(true) // dismiss current if show is called again
Dismiss When Lifecycle Destroyed¶
Balloon.Builder(context)
.setDismissWhenLifecycleOnPause(true) // dismiss on onPause
Pass Touch Events to Anchor¶
Allow touch events on the Balloon to pass through to the anchor view:
Balloon.Builder(context)
.setPassTouchEventToAnchor(true)
RTL Support¶
Enable right-to-left layout support:
Balloon.Builder(context)
.setIsRtlLayout(true)
Status Bar Visibility¶
Control whether the Balloon appears above or below the status bar:
Balloon.Builder(context)
.setIsStatusBarVisible(true)
Preferences Name¶
Set a unique name for persistence features:
Balloon.Builder(context)
.setPreferenceName("my_balloon")
Measured Size¶
Get the measured dimensions of the Balloon:
val width = balloon.getMeasuredWidth()
val height = balloon.getMeasuredHeight()
Content View Access¶
Access the internal content view for advanced customization:
val contentView: ViewGroup = balloon.getContentView()
val arrowView: View = balloon.getBalloonArrowView()