Simple Tool Tip
A simple library to add tool tips to your awesome Android application.
Download
- Gradle: Add the following to your
build.gradle
:
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
implementation 'com.github.xizzhu:simple-tool-tip:0.7.0'
}
- Maven: Add the following to your
pom.xml
:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.xizzhu</groupId>
<artifactId>simple-tool-tip</artifactId>
<version>0.7.0</version>
</dependency>
Usage
- You don't need anything special in your layout XML file:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Click Me!" />
</FrameLayout>
- Then in your Java code:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToolTip toolTip = new ToolTip.Builder()
.withText("Simple Tool Tip!")
.build();
ToolTipView toolTipView = new ToolTipView.Builder(this)
.withAnchor(v)
.withToolTip(toolTip)
.withGravity(Gravity.BOTTOM)
.build();
toolTipView.show();
}
});
}
}
- To customize your
ToolTipView
, check theToolTip.Builder
class for more details.