text-sliding bar similar to news bar

2019-07-25 06:18发布

问题:

I am trying to develop something similar to a scrolling news bar which displays news on the bottom of the tv channel. It would look something like this

..em Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ips...

It updates with newer text everytime it moves from left to right with newer content. I was thinking in using a textview flipper but it just changes from 1 entire view to another. Is there any recommendation that could assist me?

回答1:

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); 

Hope this helps.