•  


Material Tap Target Prompt | A Tap Target implementation in Android based on Material Design Onboarding guidelines.
icon Material Tap Target Prompt GitHub

Follow the quick start guide below to get started.

FAB Example

JavaDocs , examples and a sample app with examples implemented are available. The sample app is available to download on the Google Play Store: Get it on Google Play

Quick start

Gradle

Add the following to build.gradle using Maven Central:

dependencies
 {

    implementation
 'uk.co.samuelwall:material-tap-target-prompt:3.3.2'

}

Supports Android minSdkVersion 14

Usage

Tap target prompts are created with a builder class much like the Android AlertDialog builder:

Java
Kotlin
builder
 =
 new
 MaterialTapTargetPrompt
.
Builder
(
MainActivity
.
this
)

builder
 =
 MaterialTapTargetPrompt
.
Builder
(
this
@MainActivity
)

Set the view to focus the prompt on:

Java
Kotlin
builder
.
setTarget
(
R
.
id
.
target_view_id
)

builder
.
target
 =
 R
.
id
.
target_view_id

Set the text to display on the first line:

Java
Kotlin
builder
.
setPrimaryText
(
"This text is displayed on the first line"
);

builder
.
primaryText
 =
 "This text is displayed 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

Java
Kotlin
builder
.
setSecondaryText
(
"Text to display on the second line"
)

builder
.
secondaryText
 =
 "Text to display on the second line"

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
Java
Kotlin
builder
.
setPromptStateChangeListener
(
new
 MaterialTapTargetPrompt
.
PromptStateChangeListener
()

        {

            @Override

            public
 void
 onPromptStateChanged
(
MaterialTapTargetPrompt
 prompt
,
 int
 state
)

            {

                if
 (
state
 ==
 MaterialTapTargetPrompt
.
STATE_FOCAL_PRESSED
)

                {

                    // User has pressed the prompt target

                }

            }

        })

builder
.
setPromptStateChangeListener
 {
 prompt
,
 state
 ->

    if
 (
state
 ==
 MaterialTapTargetPrompt
.
STATE_FOCAL_PRESSED
)

    {

        // User has pressed the prompt target

    }

}

The Builder extends abstract class PromptOptions which contains more customisation options.

Finally show the tap target:

Java
Kotlin
builder
.
show
()

builder
.
show
()

All combined together:

Java
Kotlin
import
 uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt
;


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
();

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
()

Note

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 .

Customisation

The library is designed with extendable classes to allow for maximum customisation. More details and examples are available here .

License

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.
Edit this page
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본