2
TextView txt = new TextView(this);
    txt.setText(“This is moving text”); 
    txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    txt.setTextColor(Color.rgb(187, 88, 15));
    txt.setPadding(10, 10, 0, 0);
    txt.setEllipsize(TruncateAt.MARQUEE);
    txt.setSingleLine();
    txt.setMarqueeRepeatLimit(10);
    txt.setFocusable(true);
    txt.setHorizontallyScrolling(true);
    txt.setFocusableInTouchMode(true);
    txt.requestFocus();
    txt.setTypeface(Typeface.SERIF,Typeface.BOLD);

我试图为 textview 创建移动文本,但它不会移动。我尝试使用 setMarqueeRepeatLimit 。怎么做?

4

1 回答 1

4

答案是:

TextView txt = new TextView(this);     
txt.setText(“This is moving text”);      
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);     
txt.setTextColor(Color.rgb(187, 88, 15));     
txt.setPadding(10, 10, 0, 0);     
txt.setEllipsize(TruncateAt.MARQUEE);     
txt.setSingleLine();     
txt.setMarqueeRepeatLimit(10);     
txt.setFocusable(true);     
txt.setHorizontallyScrolling(true);     
txt.setFocusableInTouchMode(true);     
txt.requestFocus();     
txt.setLayoutParams(new TableRow.LayoutParams(130, TableRow.LayoutParams.FILL_PARENT));
txt.setTypeface(Typeface.SERIF,Typeface.BOLD); 
于 2012-09-21T12:56:00.293 回答