Comments (1)
If you run the example. You will see that the spotlight titled "Pull Down" has an example of adding a skip button. In this case the skip button visibility is delayed.
The gist is you need to set a custom message layout.
In the example project this is called SkippableMessageViewLayout.kt
class SkippableMessageViewLayout @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr), SpotlightMessage {
override var spotlightGravity: SpotlightMessageGravity? = null
override var spotlightView: SpotlightView? = null
override fun onFinishInflate() {
super.onFinishInflate()
val button = findViewById<MaterialButton>(R.id.spotlight_message_next_button)
button.setOnClickListener {
spotlightView?.endSpotlight()
}
Handler(Looper.getMainLooper()).postDelayed({
button.visibility = View.VISIBLE
}, 5000)
}
}
Then you will have to create a layout in res
. In the example this is file is spotlight_skippable_message_view.xml
<?xml version="1.0" encoding="utf-8"?>
<...SkippableMessageViewLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/simple_message_background"
android:gravity="center"
android:orientation="vertical"
android:animateLayoutChanges="true"
android:padding="10dp">
<TextView
android:id="@id/spotlight_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="18sp"
android:textStyle="bold"
tools:text="Title" />
<TextView
android:id="@id/spotlight_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="16sp"
tools:text="This is a test description" />
<com.google.android.material.button.MaterialButton
android:id="@+id/spotlight_message_next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="Skip" />
</..SkippableMessageViewLayout>
Some important notes are that the id's for the title and description are specific. In this case
@id/spotlight_description
and @id/spotlight_title
. But the layout can look anyway you want, in this example the layout adds a button.
How it looks
from spotlight.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spotlight.