1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        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è)置不同的動畫策略來實現(xiàn)不同的滾動效果

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

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

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

        字符的順序

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

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

        • 當添加多個順序時且都適用于目標字符和原字符,前面設(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

        其他

        更多的想法可自行實現(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
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            国产自国产打屁股实践2 | 日韩精品一区二区三区波多野结衣 | 欧美插菊| 神马午夜久久 | 日本护士三级少妇三级999 | ass中国裸体pics | 香蕉视频在线免费 | 啊啊啊操我视频 | 可播放男同志一级69片 | 艹逼视频免费 |