Mark James
Mark James

Reputation: 481

Android TextView Marquee programmatically

I am attempting to display a list of textviews, but need them to all Marquee. I have some code Activity (XML) somewhere that Marquee's, but I don't think I can use it here.

LinearLayout layout = (LinearLayout)findViewById(R.id.linearlayout);

for(String s : separated)
{   
    tv=new TextView(this);
    tv.setText("TEST TEXT);
    tv.setTextColor(Color.parseColor("#FFFFFF"));               

    tv.setSingleLine(true);
    tv.setEllipsize(TextUtils.TruncateAt.START);
    layout.addView(tv); 
}

Upvotes: 0

Views: 1361

Answers (1)

Aayush Puranik
Aayush Puranik

Reputation: 36

 <TextView
    android:id="@+id/TextView03"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:marqueeRepeatLimit="marquee_forever"
    android:text=""/>

 TextView textView = (TextView)findViewById(R.id.TextView03);
    textView.setText(";lkjdf;alkdsfjoiawejrokajdsl;fkadmnsflkamndvklahoreiuaweifjakldsmflkhfgoueyhtoaijpkjdflkahndsofuhyoeia");
    textView.setHorizontallyScrolling(true);
    textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    textView.setSingleLine();
    textView.setSelected(true);

Upvotes: 1

Related Questions