tooltips icon indicating copy to clipboard operation
tooltips copied to clipboard

Tooltip goes behind a cell in recycler view

Open muaviyaijaz123 opened this issue 2 years ago • 0 comments

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

muaviyaijaz123 avatar Jun 22 '23 06:06 muaviyaijaz123