Skip to content

Tooltip goes behind a cell in recycler view #50

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

Open
muaviyaijaz123 opened this issue Jun 22, 2023 · 0 comments
Open

Tooltip goes behind a cell in recycler view #50

muaviyaijaz123 opened this issue Jun 22, 2023 · 0 comments

Comments

@muaviyaijaz123
Copy link

I am showing the tooltip in a recycler view on cells . When a tooltip text is long, a tooltip is shown on a cell but a portion of it goes behind another cell in the recycler view and the arrow also goes a bit above not getting aligned with the view

Screenshots below:
Screenshot_20230622-115943_Terminal
Screenshot_20230622-115953_Terminal

Code i use:

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
    holder.mTitle.text = metricObject[position].name ?: ""

    holder.metricInfoIcon.setOnClickListener {
        val tooltipPosition = ToolTip.POSITION_RIGHT_TO
        val tooltipAlign = ToolTip.ALIGN_CENTER

        var tooltipText: String = metricObject[position].definition ?: ""

        displayToolTip(
            tooltipText,
            holder.metricInfoIcon,
            holder.rootLayout,
            tooltipPosition,
            tooltipAlign
        )
    }
}

    private fun displayToolTip(tootipText: String,imageView: ImageView,view: ViewGroup,position: Int, align: Int) {

    handler?.removeCallbacksAndMessages(null)
    toolTipsManager?.findAndDismiss(imageView)

    // get message from edit text
    val text: String = tootipText.trim()
    // set tooltip on text view

    // check condition
    if (!text.isEmpty()) {
        // when message is not equal to empty
        // create tooltip



        toolTipsManager = ToolTipsManager(this);
        val builder = ToolTip.Builder(view.context, imageView,view, text, position)
        //builder.setElevation(f)
        // set align
        builder.setAlign(align)
        builder.setTextAppearance(R.style.TooltipTextAppearance)
        val typeface = ResourcesCompat.getFont(context, R.font.inter_semibold)
        if (typeface != null) {
            builder.setTypeface(typeface)
        };
        // set background color
        builder.setBackgroundColor(ContextCompat.getColor(context,R.color.tooltip_color))
        // show tooltip
        toolTipsManager!!.show(builder.build())

        handler =  Handler(Looper.getMainLooper());

        handler?.postDelayed({
            toolTipsManager?.findAndDismiss(imageView)
        }, 3000)

    } else {
    }
}
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

2 participants
@muaviyaijaz123 and others