| layout | home |
|---|
Follow the quick start guide below to get started.
JavaDocs, examples and a sample app with examples implemented are available.
The sample app is available to download on the Google Play Store:

Add the following to build.gradle using Maven Central:
dependencies {
implementation 'uk.co.samuelwall:material-tap-target-prompt:{{ site.github.latest_release.tag_name | remove_first: "v" }}'
}Supports Android minSdkVersion 14
Tap target prompts are created with a builder class much like the Android AlertDialog builder:
Set the view to focus the prompt on:
Set the text to display on the first line:
Optionally set the text to display on the second line. If the primary text is not set the secondary text must be set
To listen in to the prompt events set a PromptStateChangeListener. Possible states are:
- STATE_NOT_SHOWN - Prompt has yet to be shown
- STATE_REVEALING - Prompt reveal animation is running
- STATE_REVEALED - Prompt reveal animation has finished and the prompt is displayed
- STATE_FOCAL_PRESSED - Prompt target has been pressed
- STATE_NON_FOCAL_PRESSED - Prompt has been pressed outside the focal area
- STATE_DISMISSING - Prompt dismiss method has been called and the prompt is being removed from view
- STATE_DISMISSED - Prompt has been removed from view after the prompt has either been pressed somewhere other than the prompt target or the system back button has been pressed
- STATE_FINISHING - Prompt finish method has been called and the prompt is being removed from view
- STATE_FINISHED - Prompt has been removed from view after the prompt has been pressed in the focal area
The Builder extends abstract class PromptOptions which contains more customisation options.
Finally show the tap target:
All combined together:
new MaterialTapTargetPrompt.Builder(MainActivity.this) .setTarget(R.id.target_view_id) .setPrimaryText("This text is displayed on the first line") .setSecondaryText("Text to display on the second line") .setPromptStateChangeListener(new MaterialTapTargetPrompt.PromptStateChangeListener() { @Override public void onPromptStateChanged(MaterialTapTargetPrompt prompt, int state) { if (state == MaterialTapTargetPrompt.STATE_FOCAL_PRESSED) { // User has pressed the prompt target } } }) .show();
</div>
<div class="tabs-content" markdown="1">
```kotlin
import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt;
MaterialTapTargetPrompt.Builder(this@MainActivity)
.setTarget(R.id.target_view_id)
.setPrimaryText("This text is displayed on the first line")
.setSecondaryText("Text to display on the second line")
.setPromptStateChangeListener { prompt, state ->
if (state == MaterialTapTargetPrompt.STATE_FOCAL_PRESSED)
{
// User has pressed the prompt target
}
}
.show()
If a target is not set or the target view could not be found or both the primary and secondary text are null then builder.show and builder.create will return null.
The library is designed with extendable classes to allow for maximum customisation. More details and examples are available here.
Copyright (C) 2016-2018 Samuel Wall
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
