Android Library that lights items for tutorials or walk-throughs etc...

Overview

Spotlight

alt text

Build Status Download License API

Gradle

dependencies {
    implementation 'com.github.takusemba:spotlight:x.x.x'
}

Usage

val spotlight = Spotlight.Builder(this)
    .setTargets(firstTarget, secondTarget, thirdTarget ...)
    .setBackgroundColor(R.color.spotlightBackground)
    .setDuration(1000L)
    .setAnimation(DecelerateInterpolator(2f))
    .setContainer(viewGroup)
    .setOnSpotlightListener(object : OnSpotlightListener {
      override fun onStarted() {
        Toast.makeText(this@MainActivity, "spotlight is started", Toast.LENGTH_SHORT).show()
      }
      override fun onEnded() {
        Toast.makeText(this@MainActivity, "spotlight is ended", Toast.LENGTH_SHORT).show()
      }
    })
    .build()         

If you want to show Spotlight immediately, you have to wait until views are laid out.

// with core-ktx method.
view.doOnPreDraw { Spotlight.Builder(this)...start() }


Target

Create a Target to add Spotlight.

Target is a spot to be casted by Spotlight. You can add multiple targets to Spotlight.

val target = Target.Builder()
    .setAnchor(100f, 100f)
    .setShape(Circle(100f))
    .setEffect(RippleEffect(100f, 200f, argb(30, 124, 255, 90)))
    .setOverlay(layout)
    .setOnTargetListener(object : OnTargetListener {
      override fun onStarted() {
        makeText(this@MainActivity, "first target is started", LENGTH_SHORT).show()
      }
      override fun onEnded() {
        makeText(this@MainActivity, "first target is ended", LENGTH_SHORT).show()
      }
    })
    .build()


Start/Finish Spotlight

val spotlight = Spotlight.Builder(this)...start()

spotlight.finish()

Next/Previous/Show Target

val spotlight = Spotlight.Builder(this)...start()

spotlight.next()

spotlight.previous()

spotlight.show(2)

Custom Shape

Shape defines how your target will look like. Circle and RoundedRectangle shapes are already implemented, but if you want your custom shape, it's arhivable by implementing Shape interface.

class CustomShape(
    override val duration: Long,
    override val interpolator: TimeInterpolator
) : Shape {

  override fun draw(canvas: Canvas, point: PointF, value: Float, paint: Paint) {
    // draw your shape here.
  }
}

Custom Effect

Effect allows you to decorates your target. RippleEffect and FlickerEffect shapes are already implemented, but if you want your custom effect, it's arhivable by implementing Effect interface.

class CustomEffect(
    override val duration: Long,
    override val interpolator: TimeInterpolator,
    override val repeatMode: Int
) : Effect {

  override fun draw(canvas: Canvas, point: PointF, value: Float, paint: Paint) {
    // draw your effect here.
  }
}

Sample

Clone this repo and check out the app module.

Author

Licence

Copyright 2017 Taku Semba.

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.
Comments
  • assign target to view..

    assign target to view..

    Hi,

    im trying to implement the library, but i cant put target as a view to method setPoint(textview1);

    the round is not fit to the view..

    any advice would help much.

    thanks

    opened by fadlifebriansyah 7
  • round rectangle spotlight

    round rectangle spotlight

    Thanks for awesome library, but I am little disappointed that there is no round rectangle option. anyone who forked and made changes for this feature?

    opened by mickychen0524 6
  • Spotlight starts at corner in every phone

    Spotlight starts at corner in every phone

     val firstRoot = LinearLayout(this)
            val first = layoutInflater.inflate(R.layout.spotlight_tour, firstRoot)
            val firstTarget = com.takusemba.spotlight.Target.Builder()
                .setAnchor(btnLoginWithEmail)
                .setEffect(RippleEffect(100f, 200f, argb(30, 124, 255, 90)))
                .setShape(RoundedRectangle(200f,400f,100f))
                .setOverlay(first)
                .build()
            val spotlight = Spotlight.Builder(this)
                .setTargets(firstTarget)
                .setBackgroundColor(R.color.spotlight_bg_color)
                .setDuration(1000L)
                .setAnimation(DecelerateInterpolator(2f))
                .build()
    
            btnLoginWithEmail.doOnPreDraw {
                spotlight.start()
            }
    // Even tried btnLoginWithEmail.post({}) but did not help
    

    By the way I am using Material design UI elements the button class is com.google.android.material.button.MaterialButton. Though I checked with regular Button class but it didn't work. In the corner again...

    opened by XiXiongMaoXiong 5
  • Show previous target

    Show previous target

    Hello,

    is there a method or some workaround to show the previous target? For moving to the next one we have spotlight.closeCurrentTarget(), anything similar for going back would be useful.

    In this way for example in a tutorial you can have all kind of buttons, skip, next but also back.

    opened by Elvereth 5
  • Manifest merger failed

    Manifest merger failed

    i had a issues. please help me.

    "Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:6:5-24:19 to override."

    opened by saviart 5
  • Spotlight position between phones

    Spotlight position between phones

    The spotlight position is different between two phone. A Pixel 2 XL emulator looks like this:

    https://i.imgur.com/G7Lcrmq.png

    but on a Pixel 3 XL phone (no emulator) it's here:

    https://i.imgur.com/7qddSSE.png

    I'm thinking the notch might be effecting the positioning.

    I'm also using 1.5.0 because 1.8.0 is throwing some manifest merge compiling error.

    bug 
    opened by krisdb 5
  • Spotlight is not started with CustomTarget

    Spotlight is not started with CustomTarget

    I created a customtarget.

    CustomTarget customtarget = new CustomTarget.Builder(activity)
                    .setPoint(viewToFocus)
                    .setRadius(50f)
                    .setView(R.layout.fab_filter_coachmark)
                    .build();
    

    Start spotlight:

    Spotlight.with(activity)
                        .setOverlayColor(ContextCompat.getColor(activity, R.color.transparent))
                        .setTargets(customtarget)
                        .setClosedOnTouchedOutside(true)
                        .start();
    

    layout : fab_filter_coachmark

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:background="@color/coachMarkBg"
        android:layout_height="match_parent">
        <TextView
            android:id="@+id/textViewDescription"
            android:layout_width="match_parent"
            android:text="Description"
            android:textColor="@color/white"
            android:layout_height="wrap_content" />
        <TextView
            android:layout_width="match_parent"
            android:text="got it"
            android:textColor="@color/blue_priceinsight"
            android:layout_height="wrap_content" />
    </LinearLayout>
    

    There are two issues

    1. Custom view is not inflated near to the target, It inflated on the top left of screen.
    2. Spotlight is not started on target.
    opened by HimanshuNarang 5
  • target.getView().getTag() return Null in OnTargetStateChangedListener

    target.getView().getTag() return Null in OnTargetStateChangedListener

    Hello, I got trouble when put data in tag view before put in setPoint method and get data in OnTargetStateChangedListener in method onStarted and onEnded, and always got null value.

    I think this is a bug.

    Sorry, my english is bad.

    Thank you

    opened by dhinx 5
  • Displaying spotLight over Dialog

    Displaying spotLight over Dialog

    Hi, the library was cool and working fine in activities and fragments. But whenever i want to display the overlay on top of dialog it was displaying below the dialog. Please suggest any possible solution..

    opened by NaveenKadiyala 4
  • Coachmark with Dialog

    Coachmark with Dialog

    Its an awesome library but I have a query how do I show the coachmark over the dialog. Its always coming behind the dialog. I am using the DialogFragment with animation in android.

    opened by mnnit-LaltuKumar 4
  • Make SpotlightView/Targetclickable

    Make SpotlightView/Targetclickable

    Can you make spotlightview or the target clickable? I know we can make a custom view and set clickable there but it would be great to make the target itself clickable to make the user tap on the target to move forward

    opened by nikhilpanju 4
  • Support for Jetpack Compose

    Support for Jetpack Compose

    Since most of the new UI development is moving toward Jetpack Compose, which is way better than XML, it would be great to have such a library for Compose.

    opened by divyanshdxn 0
  • Background blur

    Background blur

    Hello,

    Is there a way to set the background of the spotlight to a blur? Meaning that you cannot see the layout underneath the spotlight, due to the blur? I currently tried to but a view that matched parent on width and height but then it blocks the target being shown. Does anyone know a work around for this?

    Thanks!

    opened by DerSIlent 1
  • How to make spotlight persistence. If the current Configuration changes, from port to landscape, then spotlight index should persist.

    How to make spotlight persistence. If the current Configuration changes, from port to landscape, then spotlight index should persist.

    Consider a situation when there are some configuration changes. In the current spotlight, I don't think there is any way we can persist the targeted index. In my experience, if the screen is rotated, then the spotlight restart from the beginning.

    Also, consider if the user is using a different UI for different orientations, then in that case we will have to use a different layout for each target. But the thing is, the spotlight takes predefined layout targets. How can we conditionally or with some other method can change the target layout during runtime?

    opened by rishidyno 1
  • Feature: finish spotlight on touch outside of current target

    Feature: finish spotlight on touch outside of current target

    Problem

    I've seen issue https://github.com/TakuSemba/Spotlight/issues/123 (from @aryandii) and decided to help you make Spotlight more functional ✨

    Solution

    So I added a new flag to make it possible to finish spotlight on touch outside of current target. Let's see how it looks like:

    There is a listener to catch on touch outside of current target event. Finishing on touch outside is the only one usage of listener. If you want to add new Shape just create a child class and implement contains function. It can be quite complex if your shape is not primitive. So it can be not perfectly precise (and there is nothing horrible, IMHO). Round rectangle is an example of complex shape:

    @TakuSemba , thanks a lot for your work. I hope this feature will improve your project and engage new developers 🤝

    opened by valeryvpetrov-dev 1
Owner
TakuSemba
ex: CyberAgent.Inc, AbemaTv.Inc. currently, Invoice2go.Inc.
TakuSemba
A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!

RecyclerRefreshLayout English | 中文版 RecyclerRefreshLayout based on the {@link android.support.v4.widget.SwipeRefreshLayout} The RecyclerRefreshLayout

dinus_developer 1.7k Nov 10, 2022
Material Design Search View Layout, now implemented in Google Maps, Dialer, etc

THIS PROJECT IS DEPRECATED Component is not maintained anymore. Implementation of Lollipop+ Dialer and Google Maps. DEMO Add in View Add to your layou

Sahil Dave 1.1k Dec 22, 2022
ViewStateLayout - Easy way to manage common state templates like loading, empty, error etc.!

ViewStateLayout Easy way to manage common state templates like loading, empty, error etc.! How to Step 1. Add the JitPack repository to your build fil

Kamrul Hasan 7 Dec 15, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Jan 5, 2023
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Txus Ballesteros 1.5k Jan 2, 2023
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube New graphic component.

Please switch to DragView, for the best support, thank you DraggablePanel Download allprojects { repositories { ... maven { url 'https://jitp

Hoàng Anh Tuấn 103 Oct 12, 2022
FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

null 33 Dec 8, 2022
An Android library that help you to build app with swipe back gesture.

SwipeBackLayout An Android library that help you to build app with swipe back gesture. Demo Apk GooglePlay Requirement The latest android-support-v4.j

ike_w0ng 6.1k Dec 29, 2022
SwipeBack is an android library that can finish a activity by using gesture.

SwipeBack SwipeBack is a android library that can finish a activity by using gesture. You can set the swipe direction,such as left,top,right and botto

Eric 1.7k Nov 21, 2022
A very simple arc layout library for Android

ArcLayout A very simple arc layout library for Android. Try out the sample application on the Play Store. Usage (For a working implementation of this

ogaclejapan 1.4k Dec 26, 2022
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR. Android Sliding Up Panel This library provides a simp

Umano: News Read To You 9.4k Dec 31, 2022
A floating menu library for Android.

Hover Hover is a floating menu implementation for Android. Goals The goals of Hover are to: Provide an easy-to-use, out-of-the-box floating menu imple

Google 2.7k Dec 27, 2022
Simple android library to present an animated ferris wheel

Ferris Wheel View Overview An Android Library used to implement an animated Ferris Wheel in android. API SDK 15+ Written in Kotlin Supports landscape

Igor Lashkov 318 Dec 7, 2022
It's an Android library that allows you to use Layout as RadioButton or CheckBox.

Android - CompoundLayout It's an Android library that allows you to use Layout as RadioButton or CheckBox. The librarie is Android 14+ compatible. Gra

null 483 Nov 25, 2022
An Android library that help you to build app with swipe back gesture.

SwipeBackLayout An Android library that help you to build app with swipe back gesture. Demo Apk GooglePlay Requirement The latest android-support-v4.j

ike_w0ng 6.1k Jan 3, 2023
A simple customised version of the TextInputLayout from the Android Design Support Library ⌨️

Buffer Text Input Layout (Coming to maven central soon!) This is a simple customisation of the TextInputLayout found in the Design Support Library. Wh

Buffer 988 Nov 24, 2022
Share Layout Android Library

Share any layout screenshot including any string of any Android App to any app via Intent .

Amit Maity 5 Sep 13, 2022
A library that easily allows you to mask layouts/viewgroups

Maskable Layout Overview ======================= The Maskable Layout is a simple framelayout that allows you to easily mask views and viewgroups. You

Christophe Smet 654 Dec 2, 2022
A library for showing different types of layouts when a list view is empty

Android Empty Layout Please note that this project is not being maintained now. Hopefully a new version will be available soon. A library for showing

Raquib-ul Alam (Kanak) 606 Nov 26, 2022