Skip to content

ijkzen/ViewToolTip

Repository files navigation

bage week_download month_download build status

Features

  • show tip anywhere
  • show tip with gravity
  • show tip with animation including fade, slide, scale and reveal
  • set arrow location automatically
  • customize arrow width and height

Preview

Demo Download

Usage

  1. Add it in your root build.gradle at the end of repositories
allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
  1. Add the dependency

bage

dependencies {
    ...
    implementation 'com.github.ijkzen:ViewToolTip:<latest_version>'
}

Practice

  1. Example
val tip1 = ViewToolTip.on(mBinding.text1)
            .customView(binding1.root)
            .gravity(TipGravity.BOTTOM)

tip1.show()
  1. Configure ViewToolTip by chaining commands
interface ToolTipConfiguration {
    fun customView(contentView: View): ViewToolTip
    
    // Set animation for popupWindow, support fade, slide, scale and reveal
    fun animation(type: AnimationType): ToolTipConfiguration

    // For gravity top or bottom, PopupWindow will match screen width.
    fun widthMatchParent(match: Boolean): ViewToolTip

    // PopupWindow show around targetView, left, top, right or bottom.
    fun gravity(gravity: TipGravity): ViewToolTip

    // width for arrow pointing to the targetView.
    fun arrowWidth(width: Int): ViewToolTip

    // height for arrow pointing to the targetView, at most 10 dp.
    fun arrowHeight(height: Int): ViewToolTip

    // color for arrow pointing to the targetView
    fun arrowColor(color: Int): ViewToolTip

    // set background for popupWindow
    fun background(background: GradientDrawable): ViewToolTip

    // set background color for popupWindow 
    fun backgroundColor(color: Int): ViewToolTip

    // set background radius for popupWindow 
    fun backgroundRadius(radius: Int): ViewToolTip

    // set text for popupWindow if not customView
    fun text(text: CharSequence): ViewToolTip

    // set text color if not customView
    fun textColor(color: Int): ViewToolTip

    // set text size if not custmView
    fun textSize(size: Float): ViewToolTip

    //  set text alignment if not custmView
    fun textAlign(align: Int): ViewToolTip

    // show grey background for popupWindow or not
    fun isShowMaskBackground(show: Boolean): ViewToolTip

    // dismiss popupWindow when clicking grey background 
    fun isAllowHideByClickMask(allow: Boolean): ViewToolTip

    // dimiss popupWindow when clicking popupWindow
    fun isAllowHideByClickTip(allow: Boolean): ViewToolTip

    // dimiss popupWindow after sometime
    fun isAutoHide(auto: Boolean): ViewToolTip

    // sometime above
    fun displayTime(duration: Long): ViewToolTip

    // set tag for popupWindow
    fun setTag(tag: String): ViewToolTip

    // if tag == mTag, popupWindow will keep showing, otherwise, popupWindow will dismiss
    fun notify(tag: String?)
}

More

If you have any questions, please ask me here

Support

Thanks to JetBrains for supporting this project!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages