{"id":13428712,"url":"https://github.com/GwonHyeok/StickySwitch","last_synced_at":"2025-03-16T01:33:27.083Z","repository":{"id":41435407,"uuid":"84812790","full_name":"GwonHyeok/StickySwitch","owner":"GwonHyeok","description":"⭐️ beautiful switch widget with sticky animation ⭐️","archived":false,"fork":false,"pushed_at":"2023-01-18T10:33:10.000Z","size":979,"stargazers_count":774,"open_issues_count":12,"forks_count":92,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-10-27T06:38:53.035Z","etag":null,"topics":["android","android-library","animation","beautiful","library","material-design","sticky","switch"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GwonHyeok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-13T10:18:01.000Z","updated_at":"2024-08-13T16:22:12.000Z","dependencies_parsed_at":"2023-02-10T14:30:39.305Z","dependency_job_id":null,"html_url":"https://github.com/GwonHyeok/StickySwitch","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GwonHyeok%2FStickySwitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GwonHyeok%2FStickySwitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GwonHyeok%2FStickySwitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GwonHyeok%2FStickySwitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GwonHyeok","download_url":"https://codeload.github.com/GwonHyeok/StickySwitch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814905,"owners_count":20352037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","animation","beautiful","library","material-design","sticky","switch"],"created_at":"2024-07-31T01:01:03.308Z","updated_at":"2025-03-16T01:33:26.745Z","avatar_url":"https://github.com/GwonHyeok.png","language":"Kotlin","readme":"# StickySwitch\n\n[![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)]()\n[![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=15)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StickySwitch-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5433)\n[![](https://jitpack.io/v/GwonHyeok/StickySwitch.svg)](https://jitpack.io/#GwonHyeok/StickySwitch)\n\nStickySwitch library for android\n\nthis library is beautiful switch widget with sticky animation\n\n![Image of Preview](./preview.gif)\n\n## Requirements\n- Android SDK 15+\n\n## Usage\n\nAdd it in your root build.gradle at the end of repositories\n```Groovy\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\nAdd the dependency\n```Groovy\ndependencies {\n    implementation 'com.github.GwonHyeok:StickySwitch:0.0.16'\n}\n```\n\n## How to use this library\nAdd `StickySwitch` to your xml layout\n```xml\n\u003cio.ghyeok.stickyswitch.widget.StickySwitch\n        android:id=\"@+id/sticky_switch\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_centerInParent=\"true\"\n        app:ss_animationDuration=\"600\"\n        app:ss_iconPadding=\"18dp\"\n        app:ss_iconSize=\"22dp\"\n        app:ss_leftIcon=\"@drawable/ic_male\"\n        app:ss_leftText=\"Male\"\n        app:ss_rightIcon=\"@drawable/ic_female\"\n        app:ss_rightText=\"Female\"\n        app:ss_selectedTextSize=\"14sp\"\n        app:ss_sliderBackgroundColor=\"@color/colorSliderBackground\"\n        app:ss_switchColor=\"@color/colorSwitchColor\"\n        app:ss_textColor=\"@color/colorTextColor\"\n        app:ss_textSize=\"12sp\" \n        app:ss_animationType=\"line\"/\u003e\n```\n\n## Available attributes\n\n|            Name           |    Type   |  Description  |\n|:-------------------------:|:---------:|:-------------:|\n|       ss_iconPadding      | dimension |       -       |\n|        ss_iconSize        | dimension |       -       |\n|        ss_leftIcon        |  integer  |       -       |\n|        ss_leftText        |   string  |       -       |\n|        ss_rightIcon       |  integer  |       -       |\n|        ss_rightText       |   string  |       -       |\n|    ss_selectedTextSize    | dimension |       -       |\n|        ss_textSize        | dimension |       -       |\n|       ss_switchColor      |   color   |       -       |\n|  ss_sliderBackgroundColor |   color   |       -       |\n|        ss_textColor       |   color   |       -       |\n|    ss_animationDuration   |  integer  |       -       |\n|      ss_textVisibility    |    enum   |       -       |\n|    ss_animationType       |   enum    | line or curved|\n\n\n## Status change notification\nStickySwitch.Direction has two value (LEFT, RIGHT)\n\nonSelectedChange method called when you touch the switch.\n\nWhen the switch is moved to the right, the direction variable is `StickySwitch.Direction.RIGHT`\n\nalso switch is moved to the left, that variable is `StickySwitch.Direction.LEFT`\n\nJava Code Example\n```java\n// Set Selected Change Listener\nStickySwitch stickySwitch = (StickySwitch) findViewById(R.id.sticky_switch);\nstickySwitch.setOnSelectedChangeListener(new StickySwitch.OnSelectedChangeListener() {\n    @Override\n    public void onSelectedChange(@NotNull StickySwitch.Direction direction, @NotNull String text) {\n        Log.d(TAG, \"Now Selected : \" + direction.name() + \", Current Text : \" + text);\n    }\n});\n```\n\n## Direction\n### Methods\n```kotlin\nfun setDirection(direction: Direction, isAnimate: Boolean = true, shouldTriggerSelected: Boolean = true)\n```\n\n### if you want switch button direction to left\n```java\nstickySwitch.setDirection(StickySwitch.Direction.LEFT);\n```\n\n### if you want switch button direction to right without animation\n```java\nstickySwitch.setDirection(StickySwitch.Direction.RIGHT, false);\n```\n\n### if you want switch button direction to right with animation and prevent call selectedChangeListener\n```java\nstickySwitch.setDirection(StickySwitch.Direction.RIGHT, false, false);\n```\n\n### Get current Direction\n```java\nstickySwitch.getDirection(); // StickySwitch.Direction.LEFT\n```\n\n## Text\n### get current status text\n```java\nstickySwitch.getText()\n```\n\n### get specific status text\n```java\nstickySwitch.getText(StickySwitch.Direction.LEFT) // Get leftText\n```\n\n### set left or right text\n```java\nstickySwitch.setLeftText(\"Left\");\nstickySwitch.setRightText(\"Right\");\n```\n\n### set text typeface\n```java\nstickySwitch.setTypeFace(Typeface.DEFAULT_BOLD);\n```\n\n### text visibility\n```java\nstickySwitch.setTextVisibility(StickySwitch.TextVisibility.VISIBLE); // Visible Text\nstickySwitch.setTextVisibility(StickySwitch.TextVisibility.INVISIBLE); // Invisible Text\nstickySwitch.setTextVisibility(StickySwitch.TextVisibility.GONE); // GONE Text\n```\n\n## Icon\n### set left icon with drawableRes\n```java\nstickySwitch.setLeftIcon(R.mipmap.ic_launcher);\n```\n\n### set left icon with drawable\n```java\nDrawable drawable = getDrawable(R.mipmap.ic_launcher);\nstickySwitch.setLeftIcon(drawable);\n```\n\n## Color\n### set colors\n```java\n// The color format must be (0xAARRGGBB)\nstickySwitch.setSliderBackgroundColor(0xFF181821);\nstickySwitch.setSwitchColor(0xFF2371FA);\nstickySwitch.setTextColor(0xFFFFFFFF);\n```\n\n## Animation\n### custom duration\n```java\n// Animation duration to 1000ms (default duration is 600ms)\nstickySwitch.setAnimationDuration(1000);\n```\n\n### set different animation type\n```java\n// Set animation type to curved (default is line)\nstickySwitch.setAnimationType(StickySwitch.AnimationType.CURVED);\n```\n\n# Reference\n#### Talos Onboarding\n   - [dribbble](https://dribbble.com/shots/3047204-Talos-Onboarding)\n   - [material-uplabs](https://material.uplabs.com/posts/talos-onboarding)\n\n# License\n```\nMIT License\n\nCopyright (c) 2017 GwonHyeok\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","funding_links":[],"categories":["Libraries","开源库","Kotlin"],"sub_categories":["UI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGwonHyeok%2FStickySwitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGwonHyeok%2FStickySwitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGwonHyeok%2FStickySwitch/lists"}