1 Star 0 Fork 0

alan_bbs/RollingText

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

RollingTextView


preview

特性

  • 使用简单,API与TextView类似,setText方法可带有上下滚动的动画
  • 支持xml设置android:textSize/android:textColor/android:textStyle等常用属性
  • 可高度定制,支持任何单个字符的上下滚动变化效果

使用方法

xml设置

<com.yy.mobile.rollingtextview.RollingTextView
    android:id="@+id/alphaBetView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="i am text"
    android:textSize="25sp" 
    android:textColor="#1d1d1d"
    android:textStyle="bold"
    android:gravity="center"
    android:shadowColor="#ffdd00"
    android:shadowDx="4dp"
    android:shadowDy="4dp"/>

代码设置

final RollingTextView rollingTextView = findViewById(R.id.alphaBetView);
rollingTextView.setAnimationDuration(2000L);
rollingTextView.setCharStrategy(Strategy.NormalAnimation);
rollingTextView.addCharOrder(CharOrder.Alphabet);
rollingTextView.setAnimationInterpolator(new AccelerateDecelerateInterpolator());
rollingTextView.addAnimatorListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
        //finsih
    }
});
rollingTextView.setText("i am a text");

动画策略

可以通过设置不同的动画策略来实现不同的滚动效果

默认的动画是小字符向大字符变化时向下滚动,反之向上滚动

也可以指定让滚动向同一个方向

进位动画可以从低位数字进位到高位数字,不止是适用于十进制。但只能用于长度小于10的字符串防止溢出整型数。只能用于包含0的字符序列,否则进位的计算将没有意义。

StrategyCompare

字符的顺序

  • 字符的顺序需要自行设置,告诉RollingTextView怎么从原字符滚动变化到目标字符
  • 常用的字符顺序可以在 CharOrder 常量中找到
  • 当添加多个顺序时且都适用于目标字符和原字符,前面设置的优先级会更高
alphaBetView.addCharOrder(CharOrder.Alphabet);
alphaBetView.addCharOrder(CharOrder.UpperAlphabet);
alphaBetView.addCharOrder(CharOrder.Number);
alphaBetView.addCharOrder(CharOrder.Hex);
alphaBetView.addCharOrder(CharOrder.Binary);

charOrderCompare

空文件

简介

滚动的TextView 展开 收起
Kotlin 等 2 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Kotlin
1
https://gitee.com/newplanet/RollingText.git
git@gitee.com:newplanet/RollingText.git
newplanet
RollingText
RollingText
V1.0

搜索帮助