Below is the code to display scrolling text
XML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sample Text"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:id="@+id/text" />
In Java code, we have to set focus for text view to take scrolling effect.
XML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sample Text"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:id="@+id/text" />
In Java code, we have to set focus for text view to take scrolling effect.
TextView tv = (TextView) this.findViewById(R.id.text);
tv.setSelected(true); // Set focus to the textview
tv.setSelected(true); // Set focus to the textview
No comments:
Post a Comment