我正在使用滚动视图中的文本视图创建可运行的打字机效果。
这就是我所做的......
final ScrollView sv = new ScrollView(this);
sv.setLayoutParams(new LinearLayout.LayoutParams((int)display.getWidth()/2, (int)((display.getHeight()/4))*3));
sv.setPadding(0, px2DP(10), px2DP(10), px2DP(10));
final CharSequence text = getResources().getText(R.string.longstring);
final TextView content = new TextView(this);
content.setBackgroundColor(getResources().getColor(R.color.Black));
content.setTextColor(getResources().getColor(R.color.White));
content.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
content.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
sv.addView(content);
content.postDelayed(new Runnable(){
@Override
public void run() {
content.append(text.subSequence(0, index++));
sv.fullScroll(View.FOCUS_DOWN);
}
},70);
我只得到一个黑匣子,没有文字。
我究竟做错了什么?请帮忙。
PS。我已经找到了解决方案!