skydoves / Balloon

:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
https://skydoves.github.io/libraries/balloon/html/balloon/com.skydoves.balloon/index.html
Apache License 2.0
3.65k stars 284 forks source link

Balloon-Height in XML #506

Open vijay81 opened 9 months ago

vijay81 commented 9 months ago

Please complete the following information:

Describe the Bug:

I used balloon with Custom layout and set width as per screen ratio but for height used BalloonSizeSpec.WRAP but balloon take default height and not adjust as per layout PFA.

Expected Behavior:

Balloon should wrap the height as per layout.

image

image

skydoves commented 9 months ago

Hey @vijay81 thanks for raising this issue. Would you elaborate on this issue more concisely? So you set up the height with BalloonSizeSpec.WRAP but actually the height is bigger thank your expectation? It would be also very helpful if you could provide your custom xml layout.

vijay81 commented 9 months ago

Sure, below is my custom layout xml which is in data binding

`<?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools">

<data>

    <import type="android.view.View" />

    <variable
        name="viewmodel"
        type="com.incentX.businesslogic.viewmodel.crm.pager.bottomsheet.ViewModelCRMBottoms" />

    <variable
        name="generalListener"
        type="com.incentX.businesslogic.interfaces.GeneralListener" />

    <variable
        name="generalItemListener"
        type="com.incentX.businesslogic.interfaces.GeneralItemListener" />

</data>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/root_tile_config"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:focusable="true"
    app:showSnackBarIcon="@{viewmodel.mIcon}"
    app:showSnackBarInt="@{viewmodel.observerSnackBarInt}"
    app:showSnackBarString="@{viewmodel.observerSnackBarString}"
    app:showSnackBarType="@{viewmodel.observerSnackBarType}">

    <LinearLayout
        android:id="@+id/linear_tile_config"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:id="@+id/balloon_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_square_top_corners_12"
            android:backgroundTint="@color/bg_side_menu"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:padding="@dimen/margin_twelve">

            <TextView
                android:id="@+id/text_bottom_cancel"
                style="@style/IncentX.Text.Bold.Title.14.ColorPrimaryDark"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/margin_eight"
                android:layout_weight="1"
                android:ellipsize="end"
                android:maxLines="1"
                android:onClick="@{generalListener::onClick}"
                android:text="@{viewmodel.observableTitle}"
                android:textSize="@dimen/textsize_eighteen" />

            <ImageView
                android:id="@+id/img_close"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginEnd="@dimen/margin_eight"
                android:contentDescription="@null"
                android:onClick="@{generalListener::onClick}"
                android:rotation="135"
                android:src="@drawable/ic_vector_add"
                app:tint="@color/bg_view_lines" />
        </LinearLayout>

        <ScrollView
            android:id="@+id/actual_view"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:scrollbars="none">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/bg_main"
                android:orientation="vertical"
                android:paddingHorizontal="@dimen/margin_sixteen"
                android:paddingBottom="@dimen/margin_twelve">

                <TextView
                    style="@style/IncentX.Text.SemiBold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_twelve"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:text="@string/text_include_in_total"
                    app:isVisible="@{viewmodel.observableIsShowIncludeInTotal}" />

                <androidx.recyclerview.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:clipToPadding="false"
                    android:nestedScrollingEnabled="false"
                    android:orientation="horizontal"
                    android:paddingVertical="@dimen/margin_eight"
                    android:scrollbars="none"
                    app:bindGeneralItemListener="@{generalItemListener}"
                    app:bindTileConfig="@{viewmodel.observableListIncludeInTotal}"
                    app:isVisible="@{viewmodel.observableIsShowIncludeInTotal}"
                    tools:itemCount="3"
                    tools:listitem="@layout/item_tile_config" />

                <-- Other views here also -->

        </ScrollView>

        <View
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_one"
            android:background="@color/bg_view_lines"
            app:layout_constraintBottom_toTopOf="@+id/frameLayout"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />

        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_square_bottom_corners_12"
            android:backgroundTint="@color/bg_side_menu"
            android:paddingHorizontal="@dimen/margin_sixteen"
            android:paddingVertical="@dimen/margin_twelve"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">

            <Button
                android:id="@+id/btn_confirm"
                style="@style/IncentX.Button.Inverse.White.16"
                android:layout_width="match_parent"
                android:layout_height="@dimen/margin_forty"
                android:onClick="@{generalListener::onClick}"
                android:text="@string/text_confirm" />

        </FrameLayout>

    </LinearLayout>

    <ProgressBar
        style="@style/progressBarCentre"
        android:visibility="@{viewmodel.observerDialogProgressBar ? View.VISIBLE : View.GONE}"
        app:layout_constraintBottom_toBottomOf="@+id/linear_tile_config"
        app:layout_constraintEnd_toEndOf="@+id/linear_tile_config"
        app:layout_constraintStart_toStartOf="@+id/linear_tile_config"
        app:layout_constraintTop_toTopOf="@+id/linear_tile_config"
        tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

`

vijay81 commented 9 months ago

If anything you want from my end, let me know.

skydoves commented 6 months ago

Hey @vijay81, sorry for the delayed response. It seems that your custom layout can lead to misunderstanding by measuring the wrong height of the layout, especially regarding the composition of the ScrollView and RecyclerView. You should use NestedScrollView and setHasFixedSize(true) for your RecyclerView to give a hint to your layout manager to measure the expected layout size properly. I think it also would be better to specify the height size of your ScrollView or RecyclerView.

The most important thing about using a custom layout for Balloon is to give enough context to allow the popup window to measure the height size of your custom layout properly without any struggle from the end.

vijay81 commented 6 months ago

Hey @skydoves, thanks for your response. Below are some cases which i tried after your comment

  1. Set RecyclerView height as match_parent and setHasFixedSize(true)
  2. Added all views inside NestedScrollView
  3. Set fix height size of RecyclerView and NestedScrollView

after tried above cases still height issue getting same.

NOTE: I have multi RecyclerView in that custom layout and based on condition set data in recyclerView so everytime I'm not using all of them but based on condition recyclerView hide/show.

So please revert me back with your suggestion based on above condition.