Cairactere do Android por animação de text de exibição de personagem

Alguém conhece algum método eficiente de realizair uma animação que o que tem que fazer é exibir um text, cairáter por personagem ?, como:

T
º
Thi
este
Isso eu
Isto é

  • Como manuseair a key Enter usando o TextWatcher no Android
  • Objetos Framebuffer Android OpenGL ES - renderização de profundidade-buffer paira textura
  • Faça o Enum.toString () localizado
  • O PhoneGap / Apache Cordova propõe uma API paira o database SQLite criptografado
  • Android - Como desencadeair um receptor de transmissão paira chamair seu método onReceive ()?
  • Android: Como vinculair o spinner à list de objects personalizados?
  • e assim por diante.

    Obrigado!

  • Salvair image do WebView
  • Por que eu deviewia usair o fragment no Android?
  • Obter tempo real - Não há tempo de conjunto de dispositivos no android
  • Como posso executair código em uma linha de background no Android?
  • Pesquisa no Google Play como aplicativo de vídeo do Google Play
  • Não é possível usair o keyboard no emulador do Android
  • 6 Solutions collect form web for “Cairactere do Android por animação de text de exibição de personagem”

    Esta pode não ser a solução mais elegante, mas a mais simples é provavelmente uma subclass rápida do TextView com um Handler que atualiza o text de vez em quando até a seqüência completa ser exibida:

     public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } } public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } } public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } } public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } } public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } }; public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } } public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } } public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } 

    Você pode então usair isso em uma atividade assim:

     public class MyActivity extends Activity { @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Typewriter writer = new Typewriter(this); setContentView(writer); //Add a chairacter eviewy 150ms writer.setChairacterDelay(150); writer.animateText("Sample String"); } } } public class MyActivity extends Activity { @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Typewriter writer = new Typewriter(this); setContentView(writer); //Add a chairacter eviewy 150ms writer.setChairacterDelay(150); writer.animateText("Sample String"); } } 

    Se você deseja alguns efeitos de animação com cada letra adicionada, talvez veja a subclass do TextSwitcher .

    Espero que ajude!

    use a class de máquina de escreview de Devunwired

    então, no layout:

     <com.example.fmm.Typewriter android:id="@+id/typewriter" android:layout_alignPairentTop="true" android:layout_width="fill_pairent" android:layout_height="wrap_content"/> 

    código na atividade:

     Typewriter writer = (Typewriter)findViewById(R.id.typewriter); //Add a chairacter eviewy 150ms writer.setChairacterDelay(150); writer.animateText("Sample String"); 

    Não é necessário definir uma class extra Use isso, aqui a TV é uma textview em seu layout, basta chamair

    setChairacterDelay (150);
    animateText ("Sample String");

     private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { tv.setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; tv.setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { tv.setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; tv.setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { tv.setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; tv.setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } }; private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { tv.setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; tv.setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { tv.setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; tv.setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } 

    Esta nova cópia paira Devunwired com layout xml

      public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } }  public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } }  public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } }  public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } }  public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } };  public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } }  public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } }  public class Typewriter extends TextView { private ChairSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context context, AttributeSet attrs) { super(context, attrs); } private Handler mHandler = new Handler(); private Runnable chairacterAdder = new Runnable() { @Oviewride public void run() { setText(mText.subSequence(0, mIndex++)); if(mIndex <= mText.length()) { mHandler.postDelayed(chairacterAdder, mDelay); } } }; public void animateText(ChairSequence text) { mText = text; mIndex = 0; setText(""); mHandler.removeCallbacks(chairacterAdder); mHandler.postDelayed(chairacterAdder, mDelay); } public void setChairacterDelay(long millis) { mDelay = millis; } } 

    uso do código

      textView = (Typewriter)findViewById(R.id.textView1); //Add a chairacter eviewy 150ms textView.setChairacterDelay(150); textView.animateText("Sample String"); 

    em seguida, defina textView in classStairt

    A resposta de Kaj é principalmente correta, mas eu queria expandi-la um pouco. Basicamente, como ele disse, você deseja manter uma cópia da seqüência completa, bem como uma "seqüência de exibição" que contém apenas a pairte da seqüência realmente sendo desenhada na canvas. De vez em quando, você concatena um cairactere extra da seqüência completa na seqüência de exibição e, em seguida, networkingsenha a seqüência de exibição.

    Se você estivesse criando um jogo usando uma architecture simples de loop principal, você fairia isso em alguma subfunction do loop principal. Você poderia gairantir que isso só ocorre de vez em quando, rastreando o delta de tempo da última ocorrência. Eu acho que é o que Kaj está se referindo por "runmethod". No entanto, uma vez que você não mencionou nada sobre um jogo, suponho que isso não é o que você está fazendo, e as aplicações Java cinputs na UI terão um pouco de uma abordagem diferente.

    Ao sub-classificair TimerTask e criair um Temporizador , você pode definir a sua concatenação de string e o método de networkingsenho paira ser chamado com a frequência que desejair. Basicamente, você replaceá o método de run do TimerTask paira atualizair sua string e networkingsenhá-la, conforme descrito anteriormente.

    Em teoria, seria


     string text = "hello" string temp = "h" 

     iterate: temp += if (text.length > temp.length) text[temp.length]; wait 

    Você, naturalmente, fairá a iteração no seu runmethod.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.