ticker

项目地址: robinhood/ticker 简介:An Android text view with scrolling text change animation

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 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.1.0'

Usage

Define the TickerView in XML:

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"android:textColor="@color/colorPrimary"android: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);

Note that you can also specify android:textColor and android:textSize attributes usingandroid:textAppearance and provide it with an appropriate style.

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.

更多相关文章

  1. Android(安卓)studio maven pom.xml
  2. android studio 错误总结
  3. 用 Kotlin 开发现代 Android(安卓)项目 Part 2
  4. Android(安卓)Studio的build.gradle里面的各种版本信息
  5. 安卓基础学习 Day01 |第一个安卓应用程序:Hello Word!
  6. android简介
  7. Android的面试题
  8. android下开源项目
  9. MPAndroidChart项目实战(七)——自定义横向柱状图

随机推荐

  1. Vaex :突破pandas,快速分析100GB大数据集
  2. 纯Python绘制满满艺术感的山脊地图
  3. 来,一起打卡!
  4. JavaScript中的持续传递风格 [每日前端夜
  5. 【开发者必看】移动应用趋势洞察白皮书-
  6. 在模仿中精进数据可视化03:OD数据的特殊可
  7. 在模仿中精进数据可视化02:温室气体排放来
  8. 在pandas中使用数据透视表
  9. jupyter平台最强插件没有之一
  10. 推荐一个 Python 手绘图形库(附代码)