custom switch library for android. Easy to use and with all customization

Custom switch library for android. Easy to use and with all customization.

Follow these steps to use this switch:

1. Download customSwitchLibrary module fromĀ here
2. Add it in your project.
3. Add dependency to your project :

compile project(path: ':customswitchlibrary') 

4. Now it is ready to use with your project.
5. To add view in xml, write tag with this:


6. Now it is ready.

Customize in switch in xml file add below attribs :

  • Set text color for active view –  app:activeTextColor
  • Set text color for in-active view –  app:inActiveTextColor
  • Set text for first view – app:firstText
  • Set text for second view – app:secondText
  • Set view color for active view – app:activeColor
  • Set view color for in-active view – app:inActiveColor
  • Set default selected view – app:currentActive – First/Second

Customize switch from Java file : 

  • Create and findviewById.
  • Set text color for active view –  vsMySwitch.setActiveTextColor(color)
  • Set text color for in-active view –  vsMySwitch.setInActiveTextColor(color)
  • Set view color for active view – vsMySwitch.setActiveColor(color)
  • Set view color for in-active view – vsMySwitch.setInActiveColor(color)
  • Get current selected view – vsMySwitch.getCurrentPosition() returns 0/1
  • Set listener to check view selection changes – vsMySwitch.setOnStatusChangeListener(new …)

 Check customSwitch view:


Download customSwitch with sample from github

Share this content:


More Posts

Introduction to Kotlin: A Versatile and Modern Programming Language

Kotlin, a versatile and modern programming language, offers developers a concise, safe, and interoperable coding experience. With features like null safety, extension functions, and coroutines, Kotlin enhances productivity and readability, making it an attractive choice for Android development and beyond. Whether you’re new to programming or an experienced developer, exploring Kotlin opens up a world of possibilities for building robust and expressive applications.

Mastering the Android Activity Lifecycle: A Comprehensive Guide

The Android Activity Lifecycle is a fundamental concept for Android developers. It defines how an Activity behaves during its lifecycle, from creation to destruction. Understanding the Activity Lifecycle is crucial for managing resources efficiently and delivering a smooth user experience. In this blog post, we’ll briefly introduce the different states an Activity can be in and the main callback methods associated with each state. Let’s dive in and explore this important aspect of Android app development!

Table of Contents

Send Us A Message