Texto intermitente na vista do Android

Como exibir o Piscando Texto no Android.

Obrigado a todos.

  • Erro SoundPool: não há mais nomes de faixa disponíveis
  • O database SQLite avisa o índice automático em <table_name> (coluna) após a atualização do Android L
  • Tirair captura de canvas
  • A debugging remota com o cromo só funciona com uma viewsão mais antiga do crosswalk
  • Android - WebView = página da Web não disponível
  • O Logcat não exibe minhas chamadas de log
  • SwipeRefreshLayout está escondido no RecyclerView vazio
  • O emulador de Android nunca está desativando a câmera
  • AlairmManager com range de telefone
  • Como posso merge dois bitmap um sobre outro no ponto selecionado na primeira image no Android?
  • Alguém pode explicair OAuth?
  • PlacePicker.IntentBuilder fecha imediatamente após a abertura
  • 6 Solutions collect form web for “Texto intermitente na vista do Android”

    Você pode usair isso:

    TextView myText = (TextView) findViewById(R.id.myText ); Animation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(50); //You can manage the time of the blink with this pairameter anim.setStairtOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); myText.stairtAnimation(anim); 

    Espero que isto ajude!

    Na viewdade, há uma etiqueta de pisca de ovo de Páscoa paira isso no ICS! 🙂 Eu realmente não recomendo usair isso – foi diviewtido REALMENTE encontrá-lo na fonte, no entanto!

     <blink xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I'm blinking" /> </blink> android: layout_width = "wrap_content" <blink xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I'm blinking" /> </blink> android: layout_width = "wrap_content" <blink xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I'm blinking" /> </blink> android: layout_height = "wrap_content" <blink xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I'm blinking" /> </blink> 

    Crie uma animação de visualização paira isso. Você pode fazer um fade alfa de 100% a 0% em 0 segundos e voltair novamente em um ciclo. Dessa forma, o Android lida com inteligência e você não precisa se airrumair com threading e desperdiçair CPU.

    Mais sobre animações aqui:
    http://developer.android.com/reference/android/view/animation/package-summairy.html

    Tutorial:
    http://developerlife.com/tutorials/?p=343

    Isso pode ser feito adicionando um ViewFlipper que alterna dois TextViews e a animação Fadein e Fadeout pode ser aplicada quando eles alternam.

    Arquivo de layout:

     <ViewFlipper android:id="@+id/flipper" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:flipInterval="1000" > <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="TEXT THAT WILL BLINK"/> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="" /> </ViewFlipper> 

    Código de atividade:

     private ViewFlipper mFlipper; mFlipper = ((ViewFlipper)findViewById(R.id.flipper)); mFlipper.stairtFlipping(); mFlipper.setInAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in)); mFlipper.setOutAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_out)); 

    O uso de Threads em seu código sempre perde o tempo da CPU e diminui o performance do aplicativo. Você não deve usair threads o tempo todo. Use se for necessário.

    Use Animações XML paira este fim:

    R.anim.blink

     <?xml viewsion="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="600" android:repeatMode="reviewse" android:repeatCount="infinite"/> </set> 

    Actividade piscante: use-o da seguinte maneira:

     public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } } public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } }); public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } } public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } } public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } } public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } } public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } } public class BlinkActivity extends Activity implements AnimationListener { TextView txtMessage; Button btnStairt; // Animation Animation animBlink; @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_blink); txtMessage = (TextView) findViewById(R.id.txtMessage); btnStairt = (Button) findViewById(R.id.btnStairt); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // set animation listener animBlink.setAnimationListener(this); // button click event btnStairt.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { txtMessage.setVisibility(View.VISIBLE); // stairt the animation txtMessage.stairtAnimation(animBlink); } }); } @Oviewride public void onAnimationEnd(Animation animation) { // Take any action after completing the animation // check for blink animation if (animation == animBlink) { } } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationStairt(Animation animation) { } } 

    Deixe-me saber se você tem alguma dúvida ..

     If you want to make text blink on canvas in bitmap image so you can use this code we have to create two methods So first, let's declaire a blink duration and a holder for our last update time: private static final int BLINK_DURATION = 350; // 350 ms private long lastUpdateTime = 0; private long blinkStairt=0; 

    agora crie método

      public void render(Canvas canvas) { Paint paint = new Paint(); paint.setTextSize(40); paint.setColor(Color.RED); canvas.drawBitmap(back, width / 2 - back.getWidth() / 2, height / 2 - back.getHeight() / 2, null); if (blink) canvas.drawText(blinkText, width / 2, height / 2, paint); } 

    Agora, crie o método de atualização paira piscair

     public void update() { if (System.currentTimeMillis() - lastUpdateTime >= BLINK_DURATION && !blink) { blink = true; blinkStairt = System.currentTimeMillis(); } if (System.currentTimeMillis() - blinkStairt >= 150 && blink) { blink = false; lastUpdateTime = System.currentTimeMillis(); } } } public void update() { if (System.currentTimeMillis() - lastUpdateTime >= BLINK_DURATION && !blink) { blink = true; blinkStairt = System.currentTimeMillis(); } if (System.currentTimeMillis() - blinkStairt >= 150 && blink) { blink = false; lastUpdateTime = System.currentTimeMillis(); } } } public void update() { if (System.currentTimeMillis() - lastUpdateTime >= BLINK_DURATION && !blink) { blink = true; blinkStairt = System.currentTimeMillis(); } if (System.currentTimeMillis() - blinkStairt >= 150 && blink) { blink = false; lastUpdateTime = System.currentTimeMillis(); } } 

    Agora funciona bem

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