在github上有一个开源项目:JumpingBeans,其项目主页是:https://github.com/frakbot/JumpingBeans
JumpingBeans将一个普通的Android TextView中显示的字符串可以做到波浪式跳动。JumpingBeans使用起来简单,
仅仅在Android的Java代码中将一个普通Android TextView加载即可:
注意:需要jdk1.7
1 package zzw.demo; 2 3 import android.app.Activity; 4 import android.os.Bundle; 5 import android.widget.TextView; 6 import net.frakbot.jumpingbeans.JumpingBeans; 7 8 public class MainActivity extends Activity { 9 10 @Override 11 protected void onCreate(Bundle savedInstanceState) { 12 super.onCreate(savedInstanceState); 13 setContentView(R.layout.activity_main); 14 15 // 增加跳动的点 16 final TextView textView1 = (TextView) findViewById(R.id.textView1); 17 JumpingBeans jumpingBeans1 = JumpingBeans.with(textView1) 18 .appendJumpingDots() 19 .build(); 20 21 // 从第一个字符串到最后一个字符串波浪式循环跳动, textView2.getText().length()不能为0 22 final TextView textView2 = (TextView) findViewById(R.id.textView2); 23 JumpingBeans jumpingBeans2 = JumpingBeans.with(textView2) 24 .makeTextJump(0, textView2.getText().length()) 25 .setIsWave(true) 26 .setLoopDuration(3000) 27 .build(); 28 } 29 }
xml:
时间: 2024-10-10 02:24:55