Skip to content

Most visited

Recently visited

navigation

Tooltips

A tooltip is a small descriptive message that appears near a view when users long press the view or hover their mouse over it. This is useful when your app uses an icon to represent an action or piece of information to save space in the layout. This page shows you how to add these tooltips on Android 8.0 (API level 26) and higher.

Some scenarios, such as those in productivity apps, require a descriptive method of communicating ideas and actions. You can use tooltips to display a descriptive message, as shown in figure 1.

tooltip screenshot

Figure 1. Tooltip displayed in an Android app.

Some standard widgets display tooltips based on the content of the title or content description properties. Starting in Android 8.0, you can specify the text displayed in the tooltip regardless of the value of other properties.

Setting the tooltip text

You can specify the tooltip text in a View by calling the setTooltipText() method. You can set the tooltipText property using the corresponding XML attribute or API.

To specify the tooltip text in your XML files, set the android:tooltipText attribute, as shown in the following example:

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

To specify the tooltip text in your code, use the setTooltipText(CharSequence) method, as shown in the following example:

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setTooltipText("Send an email");

The API also includes a getTooltipText() method that you can use to retrieve the value of the tooltipText property.

Android displays the value of the tooltipText property when users hover their mouse over the view or long press the view.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)