例如,如果我在 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'
您可以使用这些方法。描述在链接中
关于java - 我怎样才能使android-studio中的文本具有动画效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33925293/