android - 以编程方式显示/隐藏 Android 工具提示

标签 android tooltip

Android 工具提示可以在布局中定义,并在单击或悬停在按钮上时显示。

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

有没有办法以编程方式显示/隐藏工具提示,例如

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

我想要一个可以显示/隐藏所有工具提示的帮助按钮。

最佳答案

可能这个库可以帮助您使用动画工具提示,也有关闭和隐藏 tooptip 的方法。

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

代码:

 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);

关于android - 以编程方式显示/隐藏 Android 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59514736/

相关文章:

java - 如何设置 CSS 以供我的 Java 应用程序中的所有 jtooltips 使用?

c# - 在使用附加行为单击按钮后,如何在短时间内显示工具提示?

android - 如何访问 string.xml 中的字符串

android - (强化)类别 : Android Bad Practices: Missing Google Play Services Updated Security Provider (1 Issues)

javascript - AngularJS 工具提示工具提示打开不工作

css - 使用 CSS 显示与父元素相关的工具提示

java.lang.NullPointerException : Attempt to invoke virtual method on a null object reference

android - 第二个 Activity 应该具有不同内容的 ImageView 和 TextView,具体取决于第一个 Activity 中的选择

android - Flutter/Dart应用程序在构建小部件时引发异常

label - 自定义工具提示内容@ ngx-charts | Angular2 + | typescript