Balloon
Balloon copied to clipboard
Height of balloon is not calculated properly with custom layout
Please complete the following information:
- Library Version 1.6.11
- Affected Device(s) - tested on multiple devices, like on emulator Pixel 9 Pro
Describe the Bug:
Hey folks, an issue I noticed is that when I set a custom layout and the height of the ballon to be wrapped:
return createBalloon(context) {
setLayout(R.layout.tooltip)
setHeight(BalloonSizeSpec.WRAP)
I noticed that the bottom of the text tends to get cut off.
See attached screenshot:
When I include the same layout on a regular Android layout, I don't see any problems:
Sample layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#ff0077db">
<View
android:id="@+id/icon"
android:layout_width="84dp"
android:layout_height="84dp"
android:padding="16dp"/>
<LinearLayout
android:id="@+id/text_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginVertical="16dp">
<TextView
android:id="@+id/headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sample text multiline abcqgj pjgxyz abcqgj pjgxyz"
android:textColor="#ffffffff"
android:textSize="17sp"/>
<TextView
android:id="@+id/headline_sub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sample text abcqgj pjgxyz abcqgj pjgxyz abcqgj pjgxyz"
android:textColor="#ffffffff"
android:textSize="15sp"/>
</LinearLayout>
</LinearLayout>
The issue seems to be similar to this one: https://github.com/skydoves/Balloon/issues/372 However that issue seemed to be related to supporting multiple languages, while I'm seeing this problem even for a simple use-case, using a static layout. I don't know how the layout is constructed by the library to include the arrow icon, etc., but my feeling is that something might be off there when calculating the height in certain use-cases.
Expected Behavior: Height should be calculated properly and content should not be cut off.
Hey @scorpeeon, this behavior is expected. To address it, you can specify the balloon width by using setWidthRatio(0.9f) for a percentage-based width or setWidth(450) for a fixed width in pixels.
@skydoves My problem is not with the width or default lack of horizontal spacing, I know that can be added easily - my problem is about the layout content getting cut vertically. It might not be super clear from the previous image, so I'm attaching another one to point out what I mean:
Is this a known issue?
I have the same issue with large custom layouts on height.
I also have this issue, is there any reason the height would be wrong?
Same problem, when setting Wrap content with custom Layout it become very big, if setting correct height of 158px, in end its show balloon with 60px height.