You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm using setElevation() and setArrowElevation() to add a shadow for the balloon, but it looks unnature, you can see from the screenshot.
Hope it can be looks like a real shadow, refer the MaterialDesign.
Or maybe I misunderstood how to set it ?
here is my code of the Balloon view,
@Composable
fun PopupToolTipWithText(
text: String,
display: Boolean,
alignType: PopupToolTipAlignType,
onDismiss: () -> Unit,
anchorComposable: @Composable () -> Unit,
) {
val lifeCycleOwner = LocalLifecycleOwner.current
val backgroundColor = MaterialTheme.colorScheme.secondary
val builder = rememberBalloonBuilder {
// !!! here is how I set elevation
setElevation(16)
setArrowElevation(16)
setArrowOrientationRules(ALIGN_ANCHOR)
setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
setWidth(BalloonSizeSpec.WRAP)
setHeight(BalloonSizeSpec.WRAP)
setPadding(8)
setMarginHorizontal(16)
setCornerRadius(4f)
setBackgroundColor(backgroundColor)
setBalloonAnimation(OVERSHOOT)
setOnBalloonDismissListener {
onDismiss()
}
// need to setPreferenceName with ShowCounts to avoid balloon not showing
setPreferenceName("TooltipBalloon")
setShowCounts(Int.MAX_VALUE)
// to avoid memory leak if leaving this page with balloon not dismissed
setLifecycleOwner(lifeCycleOwner)
}
Balloon(
builder = builder,
balloonContent = {
Text(
text = text,
color = MaterialTheme.colorScheme.onPrimary,
style = MaterialTheme.typography.bodySmall
)
}
) { balloonWindow ->
if (display) {
when (alignType) {
PopupToolTipAlignType.TOP -> balloonWindow.showAlignTop()
PopupToolTipAlignType.BOTTOM -> balloonWindow.showAlignBottom()
}
}
anchorComposable()
}
}
and the sample View to call the Balloon composable,
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I'm using
setElevation()
andsetArrowElevation()
to add a shadow for the balloon, but it looks unnature, you can see from the screenshot.Hope it can be looks like a real shadow, refer the MaterialDesign.
Or maybe I misunderstood how to set it ?
here is my code of the Balloon view,
and the sample View to call the Balloon composable,
Beta Was this translation helpful? Give feedback.
All reactions