Android渐变纠错效果

package com.example.myapplication4;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.view.View;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.widget.Button;import android.widget.TextView;import androidx.annotation.Nullable;import androidx.appcompat.app.AppCompatActivity;public class SkipWordActivityOne extends AppCompatActivity {    TextView mAsrTextView1;    TextView mAsrTextView2;    Button startBtn;    int count = 0;    String last;    String current;    boolean isFinish;    int duration = 150;    private Handler mHandler = new Handler() {        @Override        public void handleMessage(Message msg) {            super.handleMessage(msg);            if (msg.what == 0) {                if (count < strings1.length - 1) {                    isFinish = false;                    last = strings1[count];                    current = strings1[count + 1];                    mAsrTextView1.setText(last);                    mAsrTextView2.setText(current);                    startAnimation(1, 0, mAsrTextView1);                    startAnimation(0, 1, mAsrTextView2);                    count++;                    if(count == strings1.length - 1){                        isFinish = true;                    }                    mHandler.sendEmptyMessageDelayed(0, duration);                } else {                    isFinish = true;                }            }        }    };    private String[] strings1 = new String[]{"甚至", "设置八点", "设置八点脑中", "设置八点闹钟"};    private String[] strings2 = new String[]{"今天", "今天的", "今天的天气", "今天的天气,今天的天气"};    private String[] strings3 = new String[]{"你好,我在听...", "打开设置", "打开音乐,打开音乐"};    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_skip_word_one);        mAsrTextView1 = findViewById(R.id.asr_textView1);        mAsrTextView2 = findViewById(R.id.asr_textView2);        startBtn = findViewById(R.id.start_btn);        mHandler.sendEmptyMessageDelayed(0, duration);        startBtn.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                count = 0;                mAsrTextView1.setText("");                mAsrTextView2.setText("");                mHandler.sendEmptyMessageDelayed(0, duration);            }        });    }    private void startAnimation(int start, int end, View view) {        AlphaAnimation alphaAnimation = new AlphaAnimation(start, end);        alphaAnimation.setDuration(500);        view.startAnimation(alphaAnimation);        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {            @Override            public void onAnimationStart(Animation animation) {            }            @Override            public void onAnimationEnd(Animation animation) {                if (isFinish) {                    mAsrTextView1.setText(current);                }            }            @Override            public void onAnimationRepeat(Animation animation) {            }        });    }}

更多相关文章

  1. Android 全局背景音乐
  2. Android--Alarm,定时闹钟
  3. 【Android】Broadcast控制音乐暂停继续等
  4. android高仿抖音、点餐界面、天气项目、自定义view指示、爬取美
  5. Android简单实现音乐播放器
  6. android仿网易云音乐、即时通讯、bilibili、沙漏动画等源码
  7. android 制作的精美闹钟
  8. Android 天气预报加widget源码

随机推荐

  1. c语言取余符号是什么
  2. C语言中system()函数怎么用?
  3. c语言strlen函数用法是什么
  4. c语言%什么意思
  5. c语言合法标识符的要求是什么
  6. c语言if语句用法是什么
  7. C语言中快速排序法怎么排
  8. 学习c语言可以用什么软件?
  9. c语言如何解水仙花数
  10. 判断char型变量ch是否为大写字母的正确表