Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.ViHtarb:Tooltip:'
}
<dependency>
<groupId>com.github.ViHtarb</groupId>
<artifactId>Tooltip</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.ViHtarb" % "Tooltip" % ""
:dependencies [[com.github.ViHtarb/Tooltip ""]]
Simple to use customizable Android Tooltips library based on PopupWindow. This Tooltips does not require any custom layout. It works as PopupWindow.
For using snapshots
of development versions you need include the snapshots repo by adding the snapshot build to a dependent project. To do this add the following to your build.gradle
project(not module) file
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
dependencies {
compile 'com.github.vihtarb:tooltip:1.0.0-alpha05-SNAPSHOT'
}
<dependency>
<groupId>com.github.vihtarb</groupId>
<artifactId>tooltip</artifactId>
<version>1.0.0-alpha05-SNAPSHOT</version>
</dependency>
android:fontFamily
and android:typeface
attributes support for simple Tooltip. Use textAppearance
insteadTooltip
moduletooltipStyle
attributeBuilder.setText(int)
methodsetFocusable(isCancelable)
issue #55core
and default Tooltip
modules.core.Tooltip
and core.Tooltip.Builder
classes and implement core.Tooltip.createContentView
method. For example look to detault Tooltip
implementation.Tooltip tooltip = new Tooltip.Builder(anchorView)
.setText("Hello tooltip")
.show();
Builder(MenuItem anchorMenuItem)
Builder(MenuItem anchorMenuItem, @StyleRes int resId)
Builder(View anchorView)
Builder(View anchorView, @StyleRes int resId)
setCancelable(boolean cancelable)
- dismiss on outside touch. Default is false
setDismissOnClick(boolean isDissmissOnClick)
- dismiss on inside touch. Default is false
setArrowEnabled(boolean isArrowEnabled)
setBackgroundColor(@ColorInt int color)
- background color. Default is Color.GRAY
setCornerRadius(@DimenRes int resId)
- background drawable corner radius from resourcessetCornerRadius(float radius)
- background drawable corner radiussetArrowHeight(@DimenRes int resId)
setArrowHeight(float height)
setArrowWidth(@DimenRes int resId)
setArrowWidth(float width)
setArrow(@DrawableRes int resId)
- custom arrow drawable from resourcessetArrow(Drawable arrowDrawable)
- custom arrow drawablesetMargin(@DimenRes int resId)
- margin between arrow and anchor view from resourcessetMargin(float margin)
- margin between arrow and anchor viewsetPadding(int padding)
- content paddingsetPadding(float padding)
- deprecated, use setPadding(int padding)
insteadsetGravity(int gravity)
- Tooltip gravity. Default is Gravity.BOTTOM
setMaxWidth(int gravity)
setDrawablePadding(int gravity)
setDrawableBottom(@DrawableRes int resId)
setDrawableBottom(Drawable drawable)
setDrawableEnd(@DrawableRes int resId)
setDrawableEnd(Drawable drawable)
setDrawableStart(@DrawableRes int resId)
setDrawableStart(Drawable drawable)
setDrawableTop(@DrawableRes int resId)
setDrawableTop(Drawable drawable)
setTextAppearance(@StyleRes int resId)
setText(@StringRes int resId)
setText(String text)
setTextSize(@DimenRes int resId)
setTextSize(float size)
setTextColor(@ColorInt int color)
setTextStyle(int style)
setLineSpacing(@DimenRes int addResId, float mult)
setLineSpacing(float add, float mult)
setTypeface(Typeface typeface)
setOnClickListener(OnClickListener listener)
setOnLongClickListener(OnLongClickListener listener)
setOnDismissListener(OnDismissListener listener)
build()
- creates and returns new Tooltipshow()
- creates, shows and returns new TooltipisShowing()
- retruns is Tooltip showingshow()
- show Tooltip if not showingdismiss()
- dismissing TooltipsetOnClickListener(OnClickListener listener)
setOnLongClickListener(OnLongClickListener listener)
setOnDismissListener(OnDismissListener listener)
You can create Tooltip with custom style
Tooltip tooltip = new Tooltip.Builder(anchorView, R.style.tooltip)
.setText("Hello tooltip")
.show();
<attr name="cancelable" format="boolean"/>
- dismiss on outside touch. Default is false
<attr name="dismissOnClick" format="boolean"/>
- dismiss on inside touch. Default is false
<attr name="arrowEnabled" format="boolean"/>
<attr name="backgroundColor" format="color"/>
- background color. Default is Color.GRAY
<attr name="cornerRadius" format="dimension"/>
- background drawable corner radius<attr name="arrowHeight" format="dimension"/>
<attr name="arrowWidth" format="dimension"/>
<attr name="arrowDrawable" format="reference"/>
<attr name="margin" format="dimension"/>
- margin between arrow and anchor view<attr name="textAppearance" format="reference"/>
<attr name="android:padding"/>
- content padding<attr name="android:gravity"/>
- Tooltip gravity<attr name="android:maxWidth"/>
<attr name="android:drawablePadding"/>
<attr name="android:drawableBottom"/>
<attr name="android:drawableEnd"/>
<attr name="android:drawableStart"/>
<attr name="android:drawableTop"/>
<attr name="android:text"/>
<attr name="android:textSize"/>
<attr name="android:textColor"/>
<attr name="android:textStyle"/>
<attr name="android:fontFamily"/>
<attr name="android:typeface"/>
<attr name="android:lineSpacingExtra"/>
<attr name="android:lineSpacingMultiplier"/>
dependencies {
compile 'com.github.vihtarb:tooltip:0.2.0'
}
<dependency>
<groupId>com.github.vihtarb</groupId>
<artifactId>tooltip</artifactId>
<version>0.2.0</version>
</dependency>
Builder
methods setDrawableStart
, setDrawableEnd
, setDrawableBottom
, setDrawableTop
and for padding setDrawablePadding(int)
or styleable attributes android:drawableStart
, android:drawableEnd
, android:drawableBottom
, android:drawableTop
and for padding android:drawablePadding
(@antoninovitale)Tooltip
width by Builder
method setMaxWidth(int)
or styleable attribute android:maxWidth
(@CapnSpellcheck)Gravity.LEFT
and Gravity.RIGHT
as Tooltip
gravity, but it strongly not recommendedTooltip
arrowTooltip
content view paddingBuilder
method setPadding(float)
marked as deprecated use setPadding(int)
insteadBuilder
method setPadding(int)
now sets padding from argument not from resourcesBuilder
method setArrowEnabled(boolean)
or styleable attribute arrowEnabled
Exception android.view.WindowManager$BadTokenException:...
Tooltip
moving on scrolling/updating list viewsCharSequence
for text instead of String
(@gkravas)OnClickListener
and OnLongClickListener
listenerssetOnClickListener
and setOnLongClickListener
methods in Builder
and Tooltip
setOnDismissListener
in Tooltip
Builder
method setArrow(Drawable)
and styleable attribute arrowDrawable
TooltipActionView
classContext context
argument in Builder
constructors with second argument MenuItem anchorMenuItem
Activity has leaked window
compile ('com.github.vihtarb:tooltip:version') { exclude module: "support-compat" }