cortinico
slidetoact
Kotlin

A simple 'Slide to Unlock' Material widget for Android, written in Kotlin ๐Ÿ“ฑ๐ŸŽจ๐Ÿฆ„

Last updated May 20, 2026
1.2k
Stars
169
Forks
46
Issues
0
Stars/day
Attention Score
90
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Slide To Act

CircleCI Maven Central Android Weekly License Twitter Awesome Kotlin Badge

A simple Slide to Unlock Material widget for Android, written in Kotlin ๐Ÿ‡ฐ.

sample-slidetoact gif

* Attributes * `areamargin * innercolor & outercolor * borderradius * text, textsize, textstyle, textappearance * sliderheight * sliderlocked * animationduration * sliderreversed * slidericon * completeicon * bumpvibration * rotateicon * android:elevation * statecomplete * bounceonstart * Event callbacks * CircleCI * TravisCI * Building locally * Testing

Getting Started ๐Ÿ‘ฃ

Slide To Act is distributed through Maven Central. To use it you need to add the following Gradle dependency to your android app gradle file (NOT the root file):

<pre><code class="lang-groovy">dependencies { implementation &quot;com.ncorti:slidetoact:0.11.0&quot; }</code></pre>

Or you can download the .AAR artifact directly from Maven Central.

Example ๐Ÿšธ

After setting up the Gradle dependency, you can use SlideToActView widgets inside your XML Layout files

<pre><code class="lang-xml">&lt;com.ncorti.slidetoact.SlideToActView android:id=&quot;@+id/example&quot; android:layoutwidth=&quot;matchparent&quot; android:layoutheight=&quot;wrapcontent&quot; app:text=&quot;Example&quot; /&gt;</code></pre>

And bind them inside your Java/Kotlin code: <pre><code class="lang-java">SlideToActView sta = (SlideToActView) findViewById(R.id.example);</code></pre>

Features ๐ŸŽจ

  • 100% Vectorial, no .png or other assets provided.
  • Fancy animations! ๐Ÿฆ„
  • API >= 14 compatible (since v0.2.0)
  • Easy to integrate (just a gradle compile line).
  • Integrated with your app theme ๐Ÿ–ผ.
  • Works out of the box, no customization needed.
  • Written in Kotlin (but you don't need Kotlin to use it)!
  • UX Friendly ๐Ÿฃ, button will bump to complete if it's over the 80% of the slider (see the following gif).
<p align="center"> <img src="assets/uxfriendly.gif" alt="uxfriendly gif"/> </p>

Attributes

By the default, every SlideToActView widget fits to your app using the colorAccent and the colorBackground parameters from your theme. You can customize your SlideToActView using the following custom attributes.

<pre><code class="lang-xml">&lt;com.ncorti.slidetoact.SlideToActView android:id=&quot;@+id/examplegrayon_green&quot; android:layoutwidth=&quot;matchparent&quot; android:layoutheight=&quot;wrapcontent&quot; android:elevation=&quot;6dp&quot; app:area_margin=&quot;4dp&quot; app:animati app:outer_color=&quot;@color/green&quot; app:inner_color=&quot;@color/grey&quot; app:border_radius=&quot;2dp&quot; app:text=&quot;Testing all the custom attributes&quot; app:text_size=&quot;12sp&quot; app:slider_height=&quot;80dp&quot; app:slider_locked=&quot;false&quot; app:bounce_ /&gt;</code></pre>

area_margin

Use the area_marging attribute to control the margin of the inner circular button from the outside area. If not set, this attribute defaults to 8dp.

<p align="center"><img src="assets/areamargin1.png" alt="areamargin1" width="40%"/> <img src="assets/areamargin2.png" alt="areamargin2" width="40%"/></p>

You can also use a negative value to have the inner circular button bigger than the slider. To achieve this effect you also need to set android:clipChildren="false" on the parent layout, like:

<pre><code class="lang-xml">&lt;FrameLayout android:layoutwidth=&quot;matchparent&quot; android:layoutheight=&quot;wrapcontent&quot; android:clipChildren=&quot;false&quot;&gt;

&lt;com.ncorti.slidetoact.SlideToActView android:layoutwidth=&quot;matchparent&quot; android:layoutheight=&quot;wrapcontent&quot; app:area_margin=&quot;-8dp&quot;/&gt;</code></pre>

to obtain this behavior:

<p align="center"><img src="assets/areamargin3.png" alt="areamargin3" width="40%"/></p>

icon_margin

The attribute icon_margin let you control the margin of the icon inside the circular button. This makes the icon bigger because can take up more space in the button.

This is especially useful when you want to make the height of the slider smaller (see sliderheight). In this case, if you don't adjust the iconmargin the image can be too much tiny. By default, the icon_margin is set to 16dp.

In next image you can see how it looks like:

<p align="center"><img src="assets/iconmargin1.png" alt="iconmargin" width="40%"/> <img src="assets/iconmargin2.png" alt="iconmargin" width="40%"/></p>

innercolor & outercolor

Use the outer_color attribute to control the color of the external area and the color of the arrow icon. If not set, this attribute defaults to colorAccent from your theme.

Use the inner_color attribute to control the color of the inner circular button, the color of the tick icon and the color of the text. If not set, this attribute defaults to colorBackground from your theme.

<p align="center"><img src="assets/color1.png" alt="color1" width="40%"/> <img src="assets/color2.png" alt="color2" width="40%"/></p>

border_radius

Use the borderradius attribute to control the radius of the inner circular button and of the external area. A borderradius set to 0dp will result in a square slider. If not set, this attribute will render your slider as a circle (default behavior).

<p align="center"><img src="assets/borderradius1.png" alt="borderradius1" width="40%"/> <img src="assets/borderradius2.png" alt="borderradius2" width="40%"/></p>

text, textsize, textstyle, text_appearance

Use the text attribute to control the text of your slider. If not set, this attribute defaults to SlideToActView.

Use the textsize attribute to control the size of the text of your slider. A textsize set to 0sp will result in hiding the text. If not set, this attribute defaults to 16sp.

Use the text_style attribute to control the style of your text. Accepted values are normal, bold and italic.

Use the text_appearance attribute to provide an Android TextAppearance style to fully customize your Text. Please use this attribute if you want to use a custom font or set the text to be all caps.

<p align="center"><img src="assets/text.png" alt="slidertext" width="40%"/> <img src="assets/textappearance.png" alt="slidertextappearance" width="40%"/></p>

slider_height

Use the slider_height attribute to control the desired height of the widget. If not set, the widget will try to render with 72dp of height.

<p align="center"><img src="assets/sliderheight1.png" alt="sliderheight1" width="40%"/> <img src="assets/sliderheight2.png" alt="sliderheight2" width="40%"/></p>

slider_locked

Use the slider_locked attribute to lock the slider (this is a boolean attribute). When a slider is locked, will always bump the button to the beginning (default is false).

<p align="center"> <img src="assets/lockedslider.gif" alt="lockedslider gif"/> </p>

You can also toggle this attribute programmatically with the provided setter.

<pre><code class="lang-java">SlideToActView sta = (SlideToActView) findViewById(R.id.slider); sta.setLocked(true);</code></pre>

animation_duration

Use the animation_duration attribute to set the duration of the complete and reset animation (in milliseconds).

You can also set animation duration programmatically with the provided setter.

<pre><code class="lang-kotlin">val sta = (SlideToActView) findViewById(R.id.slider); sta.animDuration = 600</code></pre>

slider_reversed

Use the slider_reversed attribute to reverse the slider (this is a boolean attribute). When a slider is reversed, the cursor will appear on the right and will progress to the left. (default is false).

<p align="center"> <img src="assets/reversedslider.gif" alt="reversedslider gif"/> </p>

You can also toggle this attribute programmatically with the provided setter.

<pre><code class="lang-java">SlideToActView sta = (SlideToActView) findViewById(R.id.slider); sta.setReversed(true);</code></pre>

slider_icon

You can set a custom icon by setting the slider_iconattribute to a drawable resource.

<p align="center"> <img src="assets/customicon.png" alt="customicon" width="40%"/> </p>

<pre><code class="lang-xml">app:slidericon=&quot;@drawable/customicon&quot;</code></pre>

You can also set a custom icon programmatically with the provided setter.

<pre><code class="lang-java">SlideToActView sta = findViewById(R.id.slider); sta.setSliderIcon(R.drawable.custom_icon);</code></pre>

You can also disable the rotation by setting the rotate_icon attribute to false.

complete_icon

You can set a custom complete icon by setting the complete_iconattribute to a drawable resource.

<p align="center"> <img src="assets/completeicon.gif" alt="customcomplete_iconcon" width="40%"/> </p>

<pre><code class="lang-xml">app:completeicon=&quot;@drawable/slidetoactic_check&quot;</code></pre>

You can also set a custom complete icon programmatically with the provided setter.

<pre><code class="lang-java">SlideToActView sta = findViewById(R.id.slider); sta.setCompleteIcon(R.drawable.customcompleteanimated);</code></pre>

slidericoncolor

You can set a custom color for the icon by setting the slidericoncolor attribute.

<p align="center"> <img src="assets/slidericoncolor.png" alt="custom_icon" width="40%"/> </p>

This attribute defaults to the outercolor if set. If outercolor is not set, this attribute defaults to colorAccent from your theme.

bump_vibration

You can make the device vibrate when the cursor "bumps" to the end of the sliding path by setting the period of vibration through bump_vibration attribute in your layout XML (default is 0)

<pre><code class="lang-xml">app:bump_vibration=&quot;50&quot;</code></pre>

Note that the period of vibration is in milliseconds

You can achieve the same programmatically using the setter:

<pre><code class="lang-java">SlideToActView sta = (SlideToActView) findViewById(R.id.slider); sta.setBumpVibration(50);</code></pre>

In order for this feature to work, you need have the permission <pre><code class="lang-android">.permission.VIBRATE</code></pre> in your AndroidManifest.xml

<pre><code class="lang-xml">&lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot;/&gt;</code></pre>

android:elevation

Use the android:elevation attribute to set the elevation of the widget. The widgets will take care of providing the proper ViewOutlineProvider during the whole animation (a.k.a. The shadow will be drawn properly).

<p align="center"><img src="assets/elevation1.png" alt="elevation1" width="40%"/> <img src="assets/elevation2.png" alt="elevation2" width="40%"/></p>

state_complete

Use state_complete attribute to create SlideToActView in complete state.

<pre><code class="lang-xml">app:state_complete=&quot;true&quot;</code></pre>

Can be also set programmatically.

With full slide animation:

<pre><code class="lang-java">SlideToActView sta = (SlideToActView) findViewById(R.id.slider); sta.setCompleted(completed: true, withAnimation: true);</code></pre>

Without slide animation:

<pre><code class="lang-java">SlideToActView sta = (SlideToActView) findViewById(R.id.slider); sta.setCompleted(completed: true, withAnimation: false);</code></pre>

<p align="center"> <img src="assets/complete.png" alt="complete" width="40%"/> </p>

bounceonstart

You can enable a bounce animation for the slider when the view is first rendered by setting the bounceonstart attribute to true (default is false) Also you can set the duration of the bounce animation by setting the bounce_duration attribute (default is 2000) and repeat count by setting the bounce_repeat attribute (default is INFINITE)

<p align="center"> <img src="assets/bounceonstart.gif" alt="bounce on start gif"/> </p>

Event callbacks

You can use the OnSlideCompleteListener and the OnSlideResetListener to simply interact with the widget. If you need to perform operations during animations, you can provide an OnSlideToActAnimationEventListener`. With the latter, you will be notified of every animation start/stop.

You can try the Event Callbacks in the Demo app to better understand where every callback is called.

event</em>log

Demo ๐Ÿ“ฒ

Wonna see the widget in action? Just give a try to the Example App, it's inside the example folder.

Otherwise, you can just download the APK from a CircleCI build, and try it on a real device/emulator.

example</em>app gif

Building/Testing โš™๏ธ

CircleCI CircleCI

This projects is built with Circle CI. The CI environment takes care of building the library .AAR, the example app and to run the Espresso tests. Artifacts are exposed at the end of every build (both the .AAR and the .APK of the example app).

TravisCI Build Status

TravisCI builds are also running but they are considered Legacy. I'm probably going to dismiss it soon or later.

Building locally

Before building, make sure you have the following updated components from the Android SDK:

  • tools
  • platform-tools
  • build-tools-25.0.3
  • android-25
  • extra-android-support
  • extra-android-m2repository
  • extra-google-m2repository
Then just clone the repo locally and build the .AAR with the following command:
git clone git@github.com:cortinico/slidetoact.git
cd slidetoact/
./gradlew slidetoact:assemble

The assembled .AAR will be inside the slidetoact/build/outputs/aar folder.

Testing

Once you're able to build successfully, you can run Espresso tests locally with the following command.

./gradlew clean build connectedCheck

Make sure your tests are all green โœ… locally before submitting PRs.

Contributing ๐Ÿค

Looking for contributors! Don't be shy. ๐Ÿ˜ Feel free to open issues/pull requests to help me improve this project.

  • When reporting a new Issue, make sure to attach Screenshots, Videos or GIFs of the problem you are reporting.
  • When submitting a new PR, make sure tests are all green. Write new tests if necessary.

Honorable mentions ๐ŸŽ–

License ๐Ÿ“„

This project is licensed under the MIT License - see the License file for details

ยฉ 2026 GitRepoTrend ยท cortinico/slidetoact ยท Updated daily from GitHub