GithubHelp home page GithubHelp logo

tieusangaka / android-switchicon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zagum/android-switchicon

0.0 2.0 0.0 433 KB

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

License: Apache License 2.0

Java 100.00%

android-switchicon's Introduction

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 {
    compile 'com.github.zagum:Android-SwitchIcon:1.3.2'
}

Usage

SwitchIconView extends from AppCompatImageView so you can set icon with app:srcCompat

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

Use app:si_tint_color to set color to icon. Default color is black;

Use app:si_disabled_color to set color when icon disabled. Default color is equals with app:si_tint_color;

Use app:si_disabled_alpha to set alpha when icon disabled. Default alpha is .5;

Use app:si_no_dash if you don't want to draw dash, when icon disabled;

Use app:si_animation_duration if you want to change switching state animation duration;

Use app:si_enabled to set initial icon state;

Fully customized implementation:

    <com.github.zagum.switchicon.SwitchIconView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="8dp"
        app:si_animation_duration="500"
        app:si_disabled_alpha=".3"
        app:si_disabled_color="#b7b7b7"
        app:si_tint_color="#ff3c00"
        app:si_enabled="false"
        app:si_no_dash="true"
        app:srcCompat="@drawable/ic_cloud"/>

Public methods:

  public void setIconEnabled(boolean enabled);

  public void setIconEnabled(boolean enabled, boolean animate);

  public boolean isIconEnabled();

  public void switchState();

  public void switchState(boolean animate);

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.

android-switchicon's People

Contributors

elihart avatar milovan92 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.