jayrambhia / Tooltip

Lightweight Tooltip library for Android
Apache License 2.0
205 stars 25 forks source link

Tooltip

This is a lightweight library to show Tooltips dynamically in your app. This tooltip does not require any custom layout. It works out of the box with all the layouts.

Here's a short gif showing how it works.

Demo

Tooltip.Builder

Tooltip uses Builder pattern to created immutable Tooltips.

Usage

Tooltip tooltip = new Tooltip.Builder(contenxt)
                    .anchor(anchorView, Tooltip.BOTTOM)
                    .content(contentView)
                    .into(root)
                    .withTip(new Tip(tipWidth, tipHeight, tipColor))
                    .show();

That's it. It's that simple. You can customize the size and color of the tip to match color of the content view.

How To Install

JCenter / Bintray (Deprecated)

Maven
repositories {
    maven {
        url  "http://dl.bintray.com/jayrambhia/maven"
    }
}
JCenter
repositories {
    jcenter()
}
Dependency
dependencies {
    implementation 'com.fenchtose:tooltip:0.1.6'
}

JitPack

repositories {
    maven {
        url  "https://jitpack.io"
    }
}

dependencies {
    implementation 'com.github.jayrambhia:Tooltip:0.1.7-1'
}

Useful Methods:

Tip

Tip is drawn as an isosceles triangle. The length of the base is defined by width and perpendicular length between top vertex and base is defined by height.

TooltipAnimation

TooltipAnimation just holds type of the animation to be performed and duration of the animation

CoordinatorLayout and Anchored Views

When a view(eg. FAB) is anchored to another view in the CoordinatorLayout and you try to draw a tooltip as that view as anchor, it doesn't work properly. I'm assuming that CoordinatorLayout first draws fab and them moves? I don't know. Anyway, an onPreDrawListener listener has been added and once the event is received, tooltip is laid out. By default, this method is not performed. To perform this method, use checkForPreDraw(true) while creating the builder.

Future Work

Licenses and Release History

CHANGELOG

NoCropper binaries and source code can be used according to the Apache License, Version 2.0.