在github上有一个开源项目:JumpingBeans,其项目主页是:https://github.com/frakbot/JumpingBeans
JumpingBeans将一个普通的Android TextView中显示的字符串可以做到波浪式跳动。JumpingBeans使用起来简单,
仅仅在Android的Java代码中将一个普通Android TextView加载即可:
注意:需要jdk1.7
package zzw.demo; import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import net.frakbot.jumpingbeans.JumpingBeans; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // 增加跳动的点
final TextView textView1 = (TextView) findViewById(R.id.textView1);
JumpingBeans jumpingBeans1 = JumpingBeans.with(textView1)
.appendJumpingDots()
.build(); // 从第一个字符串到最后一个字符串波浪式循环跳动, textView2.getText().length()不能为0
final TextView textView2 = (TextView) findViewById(R.id.textView2);
JumpingBeans jumpingBeans2 = JumpingBeans.with(textView2)
.makeTextJump(0, textView2.getText().length())
.setIsWave(true)
.setLoopDuration(3000)
.build();
}
}
xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.zzw.testjumpingbeans.MainActivity" > <TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="http://www.cnblogs.com/zzw1994"
android:textColor="@android:color/holo_blue_light"
android:textSize="20sp" /> <TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="http://www.cnblogs.com/zzw1994"
android:textColor="@android:color/holo_red_light"
android:textSize="20sp" /> </RelativeLayout>