GithubHelp home page GithubHelp logo

irmobydick / ticker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robinhood/ticker

0.0 1.0 0.0 1.53 MB

An Android text view with scrolling text change animation

Home Page: https://medium.com/robinhood-engineering/hello-ticker-20eaf6e51689

License: Apache License 2.0

Java 100.00%

ticker's Introduction

What is Ticker?

Ticker is a simple Android UI component for displaying scrolling text. Think about how an odometer scrolls when going from one number to the next, that is similar to what Ticker does. The Ticker handles smooth animations between strings and also handle string resizing (e.g. animate from "9999" to "10000").

You can specify how the animations proceed by defining an array of characters in order. Each character displayed by Ticker is controlled by this array which dictates how to animate from a starting character to a target character. For example, if you just use a basic ASCII character list, when animating from 'A' to 'Z', it will go from 'A' -> 'B' -> ... 'Z'. The character ordering does not wrap around, meaning that to animate from 'Z' to 'A' it will go from 'Z' -> 'Y' -> ... -> 'A'.

Getting started

Add the ticker dependency to your build.gradle.

compile 'com.robinhood.ticker:ticker:1.0.0'

Usage

Define the TickerView in XML:

<com.robinhood.ticker.TickerView
    android:id="@+id/tickerView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Then add the character array to specify the animation style:

final TickerView tickerView = findViewById(R.id.tickerView);
tickerView.setCharacterList(TickerUtils.getDefaultNumberList());

That's it! Now you can call setText to display your data.

Customization

We currently support a fairly limited subset of customizations at the moment so please let us know what new features / APIs you need exposed for your use-case and we'll consider it for future releases (or of course feel free to fork!).

You can customize the looks and feels of the TickerView via XML:

android:gravity="center"
app:ticker_textColor="@color/colorPrimary"
app:ticker_textSize="16sp"
app:ticker_animationDuration="1500"

Or Java:

tickerView.setTextColor(textColor);
tickerView.setTextSize(textSize);
tickerView.setTypeface(myCustomTypeface);
tickerView.setAnimationDuration(500);
tickerView.setAnimationInterpolator(new OvershootInterpolator());
tickerView.setGravity(Gravity.START);

Performance

We decided to extend from the base View class and achieve everything by drawing directly onto the canvas. The primary benefit from this is having full flexibility and control over memory allocations and minimize performance impact by using native draw operations. We pre-allocate and pre-compute as much as possible for each transition so that the only thing we need to do in the draw path is perform the actual drawing operations. The performance test UI included in the ticker-sample is a bit over-zealous but animates smoothly with a screen full of tickers.

License

Copyright 2016 Robinhood Markets, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

ticker's People

Contributors

jinatonic avatar jawnnypoo avatar mandrizzle avatar

Watchers

MAY3AM 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.