How can I make text in android studio for animation?

For example, if I show the text “Download” in the TextView, now I want it to display the text as “Loading ...” and the three points that need to be removed, and show again, as if processing is processing something, not just static text.

I have this in the MainActivity onTouch event:

@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; } 

This line:

 status1.setText("Preparing the file"); 

Instead of displaying only the static text “Preparing the file”, I was wondering how to make it display something like moving points, such as “Preparing the file ...”, then “Preparing the file ..” and “Preparing the file”. "and again," Preparing the file ... ", then" Preparing the file .. ", etc.

+5
source share
2 answers

Use this amazing library, exactly what you are looking for: https://github.com/tajchert/WaitingDots

Add this depending

  compile 'pl.tajchert:waitingdots:0.2.0' 

and you can use the methods. Description is in the link

+2
source
 Handler handler = new Handler(); for (int i = 100; i <= 3500; i=i+100) { handler.postDelayed(new Runnable() { @Override public void run() { if(i%300 == 0){ textView.setText("Uploading."); }else if(i%200 == 0){ textView.setText("Uploading.."); }else if(i%100 == 0){ textView.setText("Uploading..."); } } }, i); } 
+1
source

Source: https://habr.com/ru/post/1236847/


All Articles