Skip to content
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

Height of balloon is not calculated properly with custom layout #770

Open
scorpeeon opened this issue Jan 10, 2025 · 3 comments
Open

Height of balloon is not calculated properly with custom layout #770

scorpeeon opened this issue Jan 10, 2025 · 3 comments

Comments

@scorpeeon
Copy link

scorpeeon commented Jan 10, 2025

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:
Screenshot 2025-01-10 at 18 47 29

When I include the same layout on a regular Android layout, I don't see any problems:
Screenshot 2025-01-10 at 18 48 05

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:
#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.

@skydoves
Copy link
Owner

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.

@scorpeeon
Copy link
Author

@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:

Image

Is this a known issue?

@javiercamarenatriguero
Copy link

I have the same issue with large custom layouts on height.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants