<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          RollingTextView帶滾動動畫的 Android TextView

          聯(lián)合創(chuàng)作 · 2023-09-24 07:02

          RollingTextView

          特性

          • 使用簡單,API與TextView類似,setText方法可帶有上下滾動的動畫

          • 支持xml設(shè)置android:textSize/android:textColor/android:textStyle等常用屬性

          • 可高度定制,支持任何單個字符的上下滾動變化效果

          動畫效果

          策略

          可以通過設(shè)置不同的動畫策略來實(shí)現(xiàn)不同的滾動效果

          默認(rèn)的動畫是小字符向大字符變化時向下滾動,反之向上滾動

          也可以指定讓滾動向同一個方向

          進(jìn)位動畫可以從低位數(shù)字進(jìn)位到高位數(shù)字,不止是適用于十進(jìn)制。但只能用于長度小于10的字符串防止溢出整型數(shù)。只能用于包含0的字符序列,否則進(jìn)位的計(jì)算將沒有意義。

          字符的順序

          • 字符的順序需要自行設(shè)置,告訴RollingTextView怎么從原字符滾動變化到目標(biāo)字符

          • 常用的字符順序可以在 CharOrder 常量中找到

          • 當(dāng)添加多個順序時且都適用于目標(biāo)字符和原字符,前面設(shè)置的優(yōu)先級會更高

          alphaBetView.addCharOrder(CharOrder.Alphabet);
          alphaBetView.addCharOrder(CharOrder.UpperAlphabet);
          alphaBetView.addCharOrder(CharOrder.Number);
          alphaBetView.addCharOrder(CharOrder.Hex);
          alphaBetView.addCharOrder(CharOrder.Binary);

          charOrderCompare

          滾動流暢度

          可以通過傳遞一個 factor 參數(shù)來調(diào)整動畫的流暢度。 factor 值越接近0.0,滾動會顯得比較跳躍。而 factor 值越接近1.0,滾動越平滑

          stickyFactor

          其他

          更多的想法可自行實(shí)現(xiàn) CharOrderStrategy 接口,定制自己的動畫效果

          配置

          1. 在App根目錄的project build.gradle文件中添加:

             allprojects {
                  repositories {
                      ...
                     maven { url 'https://jitpack.io' }
                  }
             }
          2. 在對應(yīng)的module 中添加依賴:

             dependencies {  
                 compile 'com.github.YvesCheung:RollingText:1.2.0'
             }

          使用

          xml設(shè)置

          <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"/>

          代碼設(shè)置

          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");

          許可證

          Copyright 2018 Yves Cheung
          
             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.
          瀏覽 19
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  av无码在线观看 国产精品欧美性爱 | 狠狠干AV| 手机在线看成人片 | 欧美日韩视频在线 | 国产精品无码卡一卡二 |