Giter VIP home page Giter VIP logo

siwtchview's Introduction

依赖

  1. 添加maven仓
    dependencyResolutionManagement {
      repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
      repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
      }
    }
    
  2. app层级下的build.gradle添加依赖
    dependencies {
      implementation 'com.github.fullgas-jy:siwtchView:Tag'
    }
    

使用

  • xml
    <com.jy.switchview.SwitchView
      android:id="@+id/sw"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:clickable="true" />
    
  • 可用属性
    <declare-styleable name="SwitchView">
      <attr format="boolean" name="switch_checked"/>  //开关状态
      <attr format="color" name="switch_on_color"/>  //开关打开时背景颜色
      <attr format="color" name="switch_off_color"/>  //开关关闭时背景颜色
      <attr format="color" name="switch_circle_color"/>  //开关小圆圈颜色
      <attr format="dimension" name="switch_circle_r"/>  //开关小圆圈半径
      <attr format="dimension" name="switch_circle_margin"/>  //开关小圆圈距四周margin值
    </declare-styleable>
    
  • 开关切换监听
    mBinding.sw.setICheckChanged(object : SwitchView.ICheckChangedListener {
      override fun onCheckChanged(isChecked: Boolean) {
        log("isChecked:${isChecked}")
      }
    })
    

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.