GithubHelp home page GithubHelp logo

lhn200835 / checkabletextview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jdevzone/checkabletextview

0.0 1.0 0.0 1.61 MB

A simple and flexible Checked TextView or Checkable TextView

License: MIT License

Kotlin 100.00%

checkabletextview's Introduction

CheckableTextView


Checkable TextView [KOTLIN]

⚑A simple and flexible Checked TextView or Checkable TextView written in Kotlin⚑

Android Arsenal GitHub license


What's New

Animation Demo

Normal
(duration = 250 ms)

Custom Duration
(duration = 2000 ms)

Sorry for flicker in slow motion video demo . You know android studio screen recorder sucks sometimes πŸ˜…

Custom Interpolators

custom interpolator support added

Interpolator Demo

BounceInterpolator
with fall down animation

AnticipateOvershootInterpolator
with translate animation



Installation

  1. Add it in your root build.gradle at the end of repositories:
	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
  1. Add the dependency in app gradle
	dependencies {
	        implementation 'com.github.JDevZone:CheckableTextView:{latest_version}'
	}

Basic usage

<com.devzone.checkabletextview.CheckableTextView
            app:ctv_TextStyle="@style/TextAppearance.General"
            app:ctv_IconTint="@color/colorAccent"
            app:ctv_IconChecked="true"
            app:ctv_Icon="@drawable/ic_cancel_custom_vector"
            app:ctv_Text="@string/app_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

Change State Programatically

You can change checked state as follows :

checkedTV.setChecked(isChecked)

Default value shouldNotifyListeners is false

or

checkedTV.setChecked(isChecked,shouldNotifyListeners)

First Boolean parameter isChecked sets the current state Second Boolean parameter shouldNotifyListeners determines if onCheckChange method should be called or not.

Get Current State

checkedTV.isChecked()

No Fancy enums, Just true for checked state and false for unchecked is returned

Listen State Changes

You can listen to state changes by registering a listener like as follows :

checkedTV.setOnCheckChangeListener()

and get callback in implemented method :

override fun onCheckChange(view: View, isChecked: Boolean) {
        // checkedTV returned as view
        // isChecked current state of the view
    }

Set Custom Interpolator

checkedTV.setAnimInterpolator(BounceInterpolator())

Experimental

checkedTV.setClickEnabled(isClickable: Boolean)

Pass isClickable true for enable and false for disable clicks

currently restricted to RestrictTo.Scope.LIBRARY you can use it simply Suppressing Lint Warnings (if have any) as @SuppressLint("RestrictedApi")

Customisation

Here are the attributes you can specify through XML or related setters:

  • ctv_Text - Set text.
  • ctv_TextSize - Set text size.
  • ctv_TextColor - Set text color.
  • ctv_TextStyle - Set text style.
  • ctv_Icon - Set custom icon.
  • ctv_IconTint - Set icon tint.
  • ctv_IconChecked - Set TextView (CheckableTextView) state checked.
  • ctv_TextGravity - Set text gravity.
  • ctv_AnimType - Set check animation type currently three available (scale,translate and fall_down).
  • ctv_AnimDuration - Set duration for check animation.

πŸ“„ License

Checkable TextView is released under the MIT license. See LICENSE for details.

checkabletextview's People

Contributors

jdevzone avatar fullstackdevloper avatar

Watchers

James Cloos 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.