Search code examples
androidtooltip

show/hide Android tooltips programmaticaly


Android tooltips can be defined in the layout and are displayed when clicking or hoovering over the button.

<android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:tooltipText="Send an email" />

Is there a way to Show/hide tooltips programmaticaly such as

myFabButton.showToolTip();
myFabButton.HideToolTip();

I would like to have a help button that would show/hide all tooltips.


Solution

  • Might be this library can help you with animated tooltip also have method to dismiss and hide the tooptip.

    implementation 'com.github.douglasjunior:android-simple-tooltip:0.2.3'
    

    Code :

     final SimpleTooltip tooltip = new SimpleTooltip.Builder(this)
                    .anchorView(v)
                    .text("your text")
                    .gravity(Gravity.TOP)
                    .animated(true)
                    .transparentOverlay(true)
                    .build();
            tooltip.show();
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    tooltip.dismiss();
                }
            }, 3000);