Sometimes you need to let your users know what’s possible to do in your app. Being fully material design compliant, Material Tap Target Prompt library is the best way to go about this in your Android app.
This post contains all the code that’s been written in this YouTube video.
MainActivity.kt
package com.resocoder.taptargetprep
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.preference.PreferenceManager
import kotlinx.android.synthetic.main.activity_main.*
import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt
import uk.co.samuelwall.materialtaptargetprompt.extras.backgrounds.RectanglePromptBackground
import uk.co.samuelwall.materialtaptargetprompt.extras.focals.RectanglePromptFocal
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
showFabPrompt()
}
private fun showFabPrompt(){
val prefManager = PreferenceManager.getDefaultSharedPreferences(this)
if (!prefManager.getBoolean("didShowPrompt", false)){
MaterialTapTargetPrompt.Builder(this)
.setTarget(fab)
.setPrimaryText("Click me!")
.setSecondaryText("I'm a floating action button aka FAB.")
.setBackButtonDismissEnabled(true)
.setPromptStateChangeListener { prompt, state ->
if (state == MaterialTapTargetPrompt.STATE_FOCAL_PRESSED
|| state == MaterialTapTargetPrompt.STATE_NON_FOCAL_PRESSED){
val prefEditor = prefManager.edit()
prefEditor.putBoolean("didShowPrompt", true)
prefEditor.apply()
showButtonPrompt()
}
}
.show()
}
}
private fun showButtonPrompt(){
MaterialTapTargetPrompt.Builder(this)
.setTarget(button)
.setPrimaryText("Press me!")
.setSecondaryText("I'm a nice and simple button.")
.setBackButtonDismissEnabled(true)
.setPromptBackground(RectanglePromptBackground())
.setPromptFocal(RectanglePromptFocal())
.show()
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.resocoder.taptargetprep.MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.271"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.317" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:src="@drawable/ic_fab"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.975"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.982" />
</android.support.constraint.ConstraintLayout>


I need this same tutorial using java language Help!!!
Bro can you please share this tutorial as java language Please help me bro!
Please tell me if you are putting are not?
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Thank you, your article surprised me, there is such an excellent point of view. Thank you for sharing, I learned a lot. https://www.binance.com/ph/register?ref=UM6SMJM3
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://www.binance.info/ur/register-person?ref=WTOZ531Y
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.