Movatterモバイル変換


[0]ホーム

URL:


icon Material Tap Target Prompt GitHub
Support Ukraine 🇺🇦Help Provide Humanitarian Aid to Ukraine.

Follow thequick start guide below to get started.

FAB Example

JavaDocs,examples and asample 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 abuilder class much like the Android AlertDialog builder:

Java
Kotlin
builder=newMaterialTapTargetPrompt.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:

Java
Kotlin
builder.setPromptStateChangeListener(newMaterialTapTargetPrompt.PromptStateChangeListener(){@OverridepublicvoidonPromptStateChanged(MaterialTapTargetPromptprompt,intstate){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 classPromptOptions which contains more customisation options.

Finally show the tap target:

Java
Kotlin
builder.show()
builder.show()

All combined together:

Java
Kotlin
importuk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt;newMaterialTapTargetPrompt.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(newMaterialTapTargetPrompt.PromptStateChangeListener(){@OverridepublicvoidonPromptStateChanged(MaterialTapTargetPromptprompt,intstate){if(state==MaterialTapTargetPrompt.STATE_FOCAL_PRESSED){// User has pressed the prompt target}}}).show();
importuk.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 arenull thenbuilder.show andbuilder.create will returnnull.

Customisation

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

License

Copyright (C) 2016-2018 Samuel WallLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
Edit this page

[8]ページ先頭

©2009-2025 Movatter.jp