Skip to content

dobridog/tooltip-hint

Repository files navigation

Tooltip Hint

Helps users discover which views have tooltips, so they know exactly how to reveal the tooltip.

tooltip hint demo

Integrates with native Android Tooltips through TextView Kotlin Extensions.

Download

Gradle dependency:

dependencies {
   implementation 'com.kendle.tooltip:tooltip-hint:1.0.0'
}

For release notes see releases.

Integration

There is no setup needed because Tooltip Hints are embedded into the android.widget.TextView class.

Start using android:tooltipText attribute in your layouts, or if using it already you can skip this section. See more about Tooltips Designs, Tooltips and TooltipsCompat.

 <AutoCompleteTextView
    android:tooltipText="@string/tooltip_email"
    android:id="@+id/email"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    />

To reveal a tooltip hint call View's showTooltipHint() method:

AutoCompleteTextView view = findViewById(R.id.email);
view.showTooltipHint()

Or just as well you might want to do it for the whole layout:

LinearLayout layout = findViewById(R.id.parent);
layout.showTooltipHint()

Customization

When customizing Tooltip Hint style, you need to override the "TooltipHint" (case sensitive) style definition. Also, if you inherit style from "parent = _TooltipHint" that will ensure all defaults are set.

Supported customization items:

  • android:drawable - tooltip hint icon
  • anchor - position of the icon
  • android:drawablePadding - padding around the icon

A custom style would look like this:

<style name="TooltipHint" parent="_TooltipHint">
    <item name="android:drawable">@drawable/ic_tooltip_hint</item>
    <item name="tooltipAnchor">right</item>
    <item name="android:drawablePadding">4dp</item>
</style>

Sample app

Checkout tooltip-hint-sample app for implementation details.