Width of the balloon with a custom layout not adjusted properly when setting text dynamically
See original GitHub issuePlease complete the following information:
- Library Version 1.3.1+
- Affected Device(s) All devices, in particular, Pixel 3a API 28
Describe the Bug:
We are using Balloon.Factory()
with a custom layout resource that includes several textViews. After setting text values dynamically, the width of the balloon is not resized to wrap its content (it is fixed with the initial value). As a result, the height of the content increases. The solution provided in #91 cannot be used anymore, since method measureTextWidth
is private now.
The issue can be easily reproduced using the demo application:
Step 1 - Add id to the TextView in the layout_custom_tag.xml
:
<TextView
android:id="@+id/tagTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
Step 2 - change the text of that tagTextView to a different value, i.e.:
customTagBalloon.getContentView().findViewById<TextView>(R.id.tagTextView).text = "Long text"
Step 3 - launch the application and click on the bottomNavBar. As a result, the height of the balloon increased, instead of the width. However, it works properly on version 1.3.0 of the library. Modified demo app to reproduce the issue is also available at: https://github.com/wkubaty/Balloon/tree/custom-layout-size-issue
Unexpected behavior on version 1.3.4:
Expected Behavior: The width of the balloon with a custom layout should be adjusted properly when setting content dynamically.
Proper behavior on version 1.3.0:
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (5 by maintainers)
Top GitHub Comments
I found out that if you are using
ConstrainLayout
and have any view that has0dp
for the constrain, the lib will not adapt for what you see in the editor, instead, usematch_parent
orwrap_content
for those views, or simply useLinearLayout
I will consider processing the changes internally. 🤔 Here is just the quick solution: