如果字数不多的话可以考虑自定义控件继承textView,重写TextView(Context context,AttributeSet attris)方法,自定义样式。在构造器中获取到自定义样式的属性值,然后开启一个线程,间隔一段时间想View发送消息,截取子字符串显示;代码可如下:
public class MyTextView extends TextView{
int textIndex = 0;
String text;
String subText;
ShowTextThread showTextThread;
public MyTextView(Context context){
super(context);
text = "";
}
public MyTextView(Context context,AttributeSet attrs){
super(context,attrs);
TypedArray array = context.obtainStyledAttributes(attrs,R.styleable.xxxx);
text = array.getString(R.styleable.xxxx_xxxx);
showTextThread = new ShowTextView();
showTextThread.start();
}
class ShowTextThread extends Thread{
public void run(){
while(textIndex != text.length){
subText = text.subString(0,textIndex);
postIndvalidate();
textIndex++;
}
}
}
protected void onDraw(){
setText(subText);
super.onDraw();
}
}
有问题请追问,希望对你有帮助!如果符合要求,请采纳,写这么多字,不容易啊!