joshuadeguzman / TypedKt

Animated TextView effects for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypedKt

Animated TextView effects for Android

Features

  • Modular TextEffects (on-going)
  • TypeWriterEffect
  • Customizable
  • Lightweight (Low Memory Usage)
  • Thread safe

Initial Release

  • Supports character and word animation
  • Option for custom delay
  • Option for custom string to best animated for a specific view
  • Option for callback after the animation
  • Supports loop configuration
  • Passing of custom delimiter using Regex pattern
  • Added removal of callbacks
  • Optimized method invocations

Installation

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    // Replace version with release version, e.g. 1.0.0-alpha, -SNAPSHOT
    implementation 'io.jmdg:typedkt:[VERSION]'
}

Demo

Usage

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    bt_animate.setOnClickListener {
        // Animate view with XML configuration
        tkv_animate_xml.animateText()

        // Animate by characters
        tkv_character.setLooped(true)

        // Setup options before calling this method for it to take effect
        tkv_character.animateText()

        // Animate by word
        tkv_words.setAnimationByWord()
        tkv_words.setEndAnimationListener {
            callSomeMethod()
        }
        tkv_words.setLooped(true)

        // Setup options before calling this method for it to take effect
        tkv_words.animateText()
    }

    bt_skip.setOnClickListener {
        tkv_character.skipAnimation()
        tkv_words.skipAnimation()
    }

    bt_stop.setOnClickListener {
        tkv_character.stopAnimation()
        tkv_words.stopAnimation()
    }
}
Custom configurations via code
tkv_character.setLooped(true) // default false
tkv_character.setDelay(100) // default 150
tkv_character.setAnimationByCharacter() // default animation
tkv_character.setAnimationByWord() // default by character
tkv_character.setAnimationByWord("regex pattern") // default delimiter is "\\s+" which denotes space
tkv_character.setEndAnimationListener { // default null
    callSomeMethod()
}
Custom configurations via XML
<io.jmdg.typedkt.TypedKtView
    ...
    app:animateOnLoad="false"
    app:delay="150"
    app:isAnimatedByWord="false"
    app:isLooped="false"/>
Important: Validate callbacks
override fun onResume() {
    super.onResume()
    // Resume animation
    if(tkv_animate_xml.isAnimating()){
        tkv_animate_xml.animateText()
    }

    if(tkv_character.isAnimating()){
        tkv_character.animateText()
    }

    if(tkv_words.isAnimating()){
        tkv_words.animateText()
    }
}

override fun onPause() {
    super.onPause()
    // Pause animation
    tkv_animate_xml.skipAnimation()
    tkv_character.skipAnimation()
    tkv_words.skipAnimation()
}

override fun onDestroy() {
    super.onDestroy()
    // Remove callbacks
    tkv_animate_xml.removeAnimation()
    tkv_character.removeAnimation()
    tkv_words.removeAnimation()
}

META

Joshua de Guzman | code@jmdg.io

Distributed under the MIT license.

CONTRIBUTING

  1. Fork it (https://github.com/joshuadeguzman/ButtonsKt/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

About

Animated TextView effects for Android

License:MIT License


Languages

Language:Kotlin 91.5%Language:Java 8.5%