微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – 如何让android-studio中的文本动画?

例如,如果我在TextView中显示文本“上传”,我现在希望它将文本显示为“正在上传…”,并且要删除的3个点再次显示,就像处理某事而不仅仅是静态文本一样.

我在MainActivity onTouch事件中有这个:

@Override
        public boolean onTouchEvent(MotionEvent event)
        {
            float eventX = event.getX();
            float eventY = event.getY();

            float lastdownx = 0;
            float lastdowny = 0;

            switch (event.getAction())
            {
                case MotionEvent.ACTION_DOWN:
                    lastdownx = eventX;
                    lastdowny = eventY;

                    Thread t = new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            byte[] response = null;
                            if (connectedtoipsuccess == true)
                            {

                                if (is_start == true)
                                {
                                    uploadTimerBool = true;
                                    timers.StartTimer(timerValueRecord,"Recording Time: ");
                                    response = Get(iptouse + "start");
                                    is_start = false;
                                } else
                                {
                                    timers.StopTimer(timerValueRecord);
                                    textforthespeacch = "Recording stopped and preparing the file to be shared on youtube";
                                    MainActivity.this.runOnUiThread(new Runnable()
                                    {
                                        @Override
                                        public void run()
                                        {
                                            status1.setText("Preparing the file");
                                        }
                                    });
                                    MainActivity.this.initTTS();
                                    response = Get(iptouse + "stop");
                                    is_start = true;
                                    startuploadstatusthread = true;
                                    servercheckCounter = 0;
                                }
                                if (response != null)
                                {
                                    try
                                    {
                                        a = new String(response,"UTF-8");

                                        MainActivity.this.runOnUiThread(new Runnable()
                                        {
                                            @Override
                                            public void run()
                                            {
                                                if (a.equals("Recording started"))
                                                {
                                                    status1.setText("Recording");
                                                }
                                                if (a.equals("Recording stopped and preparing the file to be shared on youtube"))
                                                {
                                                    status1.setText("Recording Stopped");
                                                }
                                            }
                                        });
                                        textforthespeacch = a;
                                        MainActivity.this.initTTS();
                                    } catch (UnsupportedEncodingException e)
                                    {
                                        e.printstacktrace();
                                    }
                                    Logger.getLogger("MainActivity(inside thread)").info(a);
                                }
                            }
                        }
                    });
                    t.start();
                    return true;
                case MotionEvent.ACTION_MOVE:
                    break;
                case MotionEvent.ACTION_UP:
                    break;
                default:
                    return false;
            }
            return true;
        }

这一行:

status1.setText("Preparing the file");

相反只显示静态文本“准备文件”我想知道如何使它显示诸如“准备文件……”之类的移动点,然后“准备文件……”和“准备文件”.再次“准备文件……”然后“准备文件……”等等.

最佳答案
使用这个真棒库,正是您正在寻找的:
https://github.com/tajchert/WaitingDots

将其添加到依赖项

 compile 'pl.tajchert:waitingdots:0.2.0'

你可以使用这些方法.描述在链接

原文地址:https://www.jb51.cc/android/437232.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐