zagum
Android-SwitchIcon
Kotlin

Google launcher-style implementation of switch (enable/disable) icon

Last updated Jun 30, 2026
2.3k
Stars
219
Forks
0
Issues
0
Stars/day
Attention Score
70
Language breakdown
Kotlin 100.0%
โ–ธ Files click to expand
README

Android-SwitchIcon ================

API

Google launcher-style implementation of switch (enable/disable) icon

image

Compatibility


This library is compatible from API 15 (Android 4.0.3).

Download


Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Add the dependency

dependencies {
    implementation 'com.github.zagum:Android-SwitchIcon:1.4.2'
}

Usage


SwitchIconView extends from AppCompatImageView so you can set icon with

:srcCompat

Set any icon (vector or image) to SwitchIconView and enjoy switchable icon in your app :)

Use

:sitintcolor
to set color to icon. Default color is black;

Use

:sidisabledcolor
to set color when icon disabled. Default color is equals with
:sitintcolor
;

Use

:sidisabledalpha
to set alpha when icon disabled. Default alpha is
.5
;

Use

:sinodash
if you don't want to draw dash, when icon disabled;

Use

:sianimationduration
if you want to change switching state animation duration;

Use

:si_enabled
to set initial icon state;

Fully customized implementation:

<com.github.zagum.switchicon.SwitchIconView
        android:layoutwidth="wrapcontent"
        android:layoutheight="wrapcontent"
        android:padding="8dp"
        app:si_animati
        app:sidisabledalpha=".3"
        app:sidisabledcolor="#b7b7b7"
        app:sitintcolor="#ff3c00"
        app:si_enabled="false"
        app:sinodash="true"
        app:srcCompat="@drawable/ic_cloud"/>

Public methods and fields:

var isIconEnabled: Boolean

fun setIconEnabled(enabled: Boolean, animate: Boolean = true)

fun switchState(animate: Boolean = true)

See sample project for more information.

License


Copyright 2017 Evgenii Zagumennyi 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.

ยฉ 2026 GitRepoTrend ยท zagum/Android-SwitchIcon ยท Updated daily from GitHub