1

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.

Nathalie
  • 625
  • 6
  • 19

3 Answers3

1

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);
halfer
  • 19,824
  • 17
  • 99
  • 186
haresh
  • 1,424
  • 2
  • 12
  • 18
  • Please try to refrain from "hope that helps" and "happy coding" messages. They are generally regarded as a form of spam here, and they are not likely to increase your chance of upvotes. Please take note of the edits being made to your posts, and adjust your future answers accordingly. – halfer Dec 29 '19 at 17:01
1

You can use : For showing tooltip

myFabButton.performLongClick()

and to hide it.

myFabButton.setTooltipText(null)

Set empty string or null as a tooltip text automatically hide it.

Sirelon
  • 6,446
  • 5
  • 26
  • 30
0

First checkout the material recommendations to see what are the right bounds: https://material.io/components/tooltips/#

the current native component I think is: https://developer.android.com/reference/androidx/appcompat/widget/TooltipCompat

Try: https://developer.android.com/guide/topics/ui/tooltips.html

If you want tooltip with arrow look to Android PopupWindow with Tooltip Arrow

halfer
  • 19,824
  • 17
  • 99
  • 186