Giter VIP home page Giter VIP logo

typewriter-textview's Introduction

Header

Demo

Demo

Gradle Dependency

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file

Add it in your project level build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency to app level build.gradle file

	dependencies {
	        implementation 'com.github.NitishGadangi:TypeWriter-TextView:v1.3'
	}

Usage

Step 1. Add TypeWriterView to your XML file

<com.nitish.typewriterview.TypeWriterView  
  android:id="@+id/typeWriterView"  
  android:layout_width="match_parent"  
  android:layout_height="wrap_content"  
 />

Step 2. Start animation in Activity or Fragment

TypeWriterView typeWriterView = findViewById(R.id.typeWriterView);
typeWriterView.animateText("Insert your text here");

Listeners and Functions

Callback for OnAnimation End

typeWriterView.setOnAnimationChangeListener(new TypeWriterView.OnAnimationChangeListener() {  
    @Override  
  public void onAnimationEnd() {  
          //Do something
    }  
});

Other Functions

typeWriterView.isAnimationRunning(); //returns true if animation is still running
typeWriterView.stopAnimation(); //Stop the ongoing animation
typeWriterView.isTextInitialised(); //returns false if animation is not started

Customization

By default

avoidTextOverflowAtEdge = true;
characterDelay = 40; //in ms

You can modify the following values

//set characterDelay in ms
typeWriterView.setCharacterDelay(long millis);
//making this false will turnoff adding new line when the view hits the end of the view
typeWriterView.avoidTextOverflowAtEdge(boolean avoidTextOverflowAtEdge);

Contributing

Pull requests are welcome, if you have any questions feel free to ping me.

Like my work?

Buy me a coffee

Made with ❤️ by Nitish

typewriter-textview's People

Contributors

nitishgadangi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

typewriter-textview's Issues

Crashing Caused by Index Out of bound

getting this index out of bound exception Error No reason at all

  java.lang.StringIndexOutOfBoundsException: begin 0, end 32, length 31
                 	at java.lang.String.checkBoundsBeginEnd(String.java:4466)
                 	at java.lang.String.substring(String.java:2517)
                 	at java.lang.String.subSequence(String.java:2567)
                 	at com.nitish.typewriterview.TypeWriterView$1.run(TypeWriterView.java:31)
                 	at android.os.Handler.handleCallback(Handler.java:942)
                 	at android.os.Handler.dispatchMessage(Handler.java:99)
                 	at android.os.Looper.loopOnce(Looper.java:204)
                 	at android.os.Looper.loop(Looper.java:291)
                 	at android.app.ActivityThread.main(ActivityThread.java:8134)
                 	at java.lang.reflect.Method.invoke(Native Method)
                 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
                 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)

here is my Implementation if you can help narrow down the issue please help

` private fun makeTypingText() {

    homeBinding.searchWriterView.setCharacterDelay(80)
    homeBinding.searchWriterView.animateText("Explore Deliciousness in Every Search..")


    homeBinding.searchWriterView.setOnAnimationChangeListener {
        Handler(Looper.getMainLooper()).postDelayed(Runnable {
            if ([email protected]) {
                try {
                    if (index == 4) {
                        index = 0
                    }
                    index++

                    homeBinding.searchWriterView.animateText(makeTestList(index))
                }catch (e:Exception){
                    e.printStackTrace()
                }

            }
        }, 1500)
    }



}
val animatableText: ArrayList<String> = ArrayList()

private fun makeTestList(index: Int): String {
    if(animatableText.isEmpty()) {
        animatableText.add("Explore Deliciousness in Every Search..")
        animatableText.add("Find Flavorful Delights Here...")
        animatableText.add("Explore Deliciousness...")
        animatableText.add("Where Every Bite Speaks Flavor...")
        animatableText.add("Uncover Delicious Treasures Instantly...")
    }
    return animatableText[index]
}`

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.