-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Balloon does not adapt to the height of a custom View #148
Comments
Hi, @cooltey! |
Thank you @skydoves
Looking forward to see the upcoming release :) Thank you. |
We should use the val title = customProfileBalloon.getContentView().findViewById<TextView>(R.id.text1)
customProfileBalloon.measureTextWidth(title)
val content = customProfileBalloon.getContentView().findViewById<TextView>(R.id.text2)
customProfileBalloon.measureTextWidth(content) We can resolve that issue like this temporarily but I will find a more polished way to resolve this issue. |
@cooltey |
Hi @skydoves, thanks for the quick fixes 👍 But unfortunately, looks like the issue is still there, here are the screenshots in different font-sizes: You may notice that the right edge is cutting off and maybe that's the cause of the issue. Here is the PR I have created: |
Hi, @cooltey |
Hi @skydoves and you can see the changes here: |
Thanks for your details! I just found the problem is And I just pushed a commit for testing the measuring is being correct. The solution is just creating an If we want to use the Thanks! |
Makes sense. Thanks for checking :) |
@skydoves first of all thank you for all your work/help on this library. I'm facing a similar issue to this one, but I'm not using a custom layout nor a icon. I'm trying to display this text in the balloon binding.ivTooltip.setOnClickListener(tooltipView -> new Balloon.Builder(tooltipView.getContext())
.setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
.setBackgroundColorResource(R.color.tooltip_background)
.setTextColorResource(R.color.white)
.setCornerRadiusResource(R.dimen.margin_md)
.setWidthRatio(1f)
.setPaddingResource(R.dimen.margin_xs)//6dp
.setMarginLeftResource(R.dimen.margin_xl)//32dp
.setMarginRightResource(R.dimen.margin_xl)//32dp
.setTextSizeResource(R.dimen.font_mdl)//16sp NOT SURE IF THIS COULD BE CAUSING THE ISSUE
.setDismissWhenClicked(true)
.setTextResource(tooltipInfoRes)
.setLifecycleOwner(getViewLifecycleOwner())
.build()
.showAlignTop(tooltipView)
); |
I'm sorry @skydoves, is this issue already fixed(I see the |
Hi, @epool. |
A new stable version 1.3.2 is released! |
Hi @skydoves, thanks for the new release. Not sure if we did the configuration incorrectly or something else, the existing code for the plain text Balloon also has the issue that the text is being cut off on the right side, should we update the current configuration? |
Hi, @cooltey.
You may need to add this to your gradle file.
If this issue would be fixed, I will release the next stable version. |
Thanks, @skydoves, the SNAPSHOT version looks pretty good to me! It fixes all the issues 💯 👍 Looking forward to seeing the latest release, and thanks again for your hard works! |
@skydoves Thanks and I will absolutely add it to the license page :) |
@skydoves v1.3.3 fixed the issue on our side, thank you so much!!! 🙌🏼 |
Hi @skydoves Just notice that the issue still happens on the Pixel 2 and Pixel 3XL, but works fine on Samsung S9. Do you have any idea on how to fix it? |
Same height of a custom view problem in Galaxy A9 in 1.3.9
|
I have the same issue with the version below: Devide model : Xiaomi POCO F3 I am using TopAppBar and I set to actions the element below: SimpleTooltip(
showTooltip = instructionsTooltipIsVisible,
title = "Game Instructions",
description = "Whenever you want, you can see the instructions of the game from this button.,
textAlignment = TextAlign.Start,
tooltipAlignment = BalloonAlign.BOTTOM,
onTooltipDismiss = { mainGameViewModel.instructionsTooltipDismissed() }
) {
IconButton(onClick = { mainGameViewModel.showInstructions() }) {
Icon(imageVector = Icons.Outlined.Info, contentDescription = null, tint = BasePalette.onBackground)
}
} As far as the SimpleToolTip, I use this composable view: @Composable
fun SimpleTooltip(
showTooltip: Boolean = false,
title: String? = "",
description: String? = "",
textAlignment: TextAlign = TextAlign.Center,
tooltipAlignment: BalloonAlign = BalloonAlign.BOTTOM,
isCircle: Boolean = true,
onTooltipDismiss: (() -> Unit)? = null,
selectedElement: @Composable () -> Unit = {}
) {
Balloon(
balloonContent = {
Column {
if (title?.isNotEmpty() == true) {
Text(
modifier = Modifier.wrapContentWidth(),
text = title,
textAlign = textAlignment,
style = BaseTypography.body1.copy(fontWeight = FontWeight.Bold),
color = BasePalette.onSurface
)
Spacer(modifier = Modifier.height(4.dp))
}
if (description?.isNotEmpty() == true) {
Text(
modifier = Modifier.wrapContentWidth(),
text = description,
textAlign = textAlignment,
style = BaseTypography.subtitle1,
color = BasePalette.onSurface
)
}
}
},
builder = rememberBalloonBuilder {
setWidth(BalloonSizeSpec.WRAP)
setHeight(BalloonSizeSpec.WRAP)
setArrowSize(10)
setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
setArrowPosition(0.5f)
setMarginLeft(16)
setMarginRight(16)
setPadding(12)
setCornerRadius(16f)
setBackgroundColor(BasePalette.surface)
setBalloonAnimation(BalloonAnimation.ELASTIC)
setIsVisibleOverlay(true)
setOverlayColor(BasePalette.background.copy(0.8f))
setOverlayPadding(16f)
setBalloonHighlightAnimation(BalloonHighlightAnimation.SHAKE)
setOverlayShape(
if (isCircle) {
BalloonOverlayCircle(100f)
} else {
BalloonOverlayRoundRect(16f, 16f)
}
)
setDismissWhenClicked(true)
// This is because the balloon was cut during animation
if (tooltipAlignment == BalloonAlign.TOP) {
setMarginTop(16)
} else if (tooltipAlignment == BalloonAlign.BOTTOM) {
setMarginBottom(16)
}
}
) { balloonWindow ->
selectedElement.invoke()
if (showTooltip && (title?.isNotEmpty() == true || description?.isNotEmpty() == true)) {
balloonWindow.setOnBalloonDismissListener {
onTooltipDismiss?.invoke()
}
when (tooltipAlignment) {
BalloonAlign.START -> balloonWindow.showAlignLeft()
BalloonAlign.END -> balloonWindow.showAlignRight()
BalloonAlign.TOP -> balloonWindow.showAlignTop()
BalloonAlign.BOTTOM -> balloonWindow.showAlignBottom()
}
}
}
} |
Please complete the following information:
com.github.skydoves:balloon:1.2.7
Describe the Bug:
We have implemented Balloon with a custom layout. Although the height has specified, some of the text will be cut out if the user adjusts the system font-size.
Code:
https://github.com/wikimedia/apps-android-wikipedia/blob/22b07cdefc8fd184601ae657a2b01dcefd31ed57/app/src/main/java/org/wikipedia/util/FeedbackUtil.java#L226-L234
Expected Behavior:
The library adapts the height of the custom view automatically.
I have checked #112 but it does not work for me.
The text was updated successfully, but these errors were encountered: