Tooltip


Source link: https://github.com/jayrambhia/Tooltip

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.

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

Maven

repositories {

  maven {

url  "http://dl.bintray.com/jayrambhia/maven"
  
}
 
}
 

JCenter

repositories {

  jcenter() 
}
 

Dependency

dependencies {

  compile 'com.fenchtose:tooltip:0.1.5' 
}
 

Useful Methods:

  • anchor(View view) - set anchor view with position as Tooltip.TOP
  • anchor(View view, @Position int position) - set anchor view with position
  • content(View view) - set content view of the tooltip
  • animate(@NonNull TooltipAnimation animation) - set Animation for Show and Dismiss
  • withTip(@NonNull Tip tip) - set Tip of the tooltip.
  • into(ViewGroup viewGroup) - set ViewGroup into which the tip is to be shown
  • autoAdjust(boolean adjust) - if you want the tooltip to adjust itself if going out of bound
  • cancelable(boolean cancelable) - if you want the tooltip to dismiss automatically if clicked outside. Default is true
  • withPadding(int padding) - distance from the anchor and screen boundaries
  • autoCancel(int timeInMS) - if tooltip should be dismissed automatically after given time. If value is <= 0, auto cancel is off
  • withListener(@NonNull Listener listener) - Attach dismiss listener.
  • debug(boolean debug) - Enable debugging mode. Default is false.
  • checkForPreDraw(boolean check) - Check if the anchor is drawn or not and then only draw the tooltip

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.

  • width - length of the base of isosceles triangle
  • height - length of the perpendicular from top vertex to the base
  • color - Color of the tip
  • tipRadius - Corner radius of the tip

TooltipAnimation

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

  • type - Type of animation - FADE, SCALE, REVEAL, SCALE_AND_FADE
  • duration - Animation duration in milliseconds

Animations are a bit tricky in this library. FADE and REVEAL are applied on the container of the tooltip with appropriate parameters. So if the container has some background color, it looks really weird. The same method can't be applied for SCALE because it doesn't draw the tooltip properly. So in SCALE, the animation is applied on Tooltip's content view (and if tip is present, it will be there as it is not part of the content view). To avoid this eye sore, you may use SCALE_AND_FADE, it does SCALE and FADE so the poor effect is not visible.

REVEAL uses Circular Reveal and hence is supported for API 21 and above.

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

  • Customizable tips
  • Shadow
  • Improve and add more animations

Licenses and Release History

CHANGELOG

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

Resources

A custom ImageButton that invoke onClickListener only when touch is inside the circle not outside (rectangle area of button).

Project vlayout is a powerfull LayoutManager extension for RecyclerView, it provides a group of layouts for RecyclerView. Make it able to handle a complicate situation when grid, list and other layouts in the same recyclerview.

Simple and easy json parser, json generator, and data holder based on JSONArray and JSONObject for android.

Pinview library for Android.

Material Chip view can be used as tags for categories, contacts or creating text clouds.

Android library with collection of cool progress views. Initially the library has 5 designs for showing the progress in android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes