Scroll TextView like Marquee in android - android

I am having a TextView and want to automatically scroll horizontally. i know it can be done using ellipsize property of text view. Please help me on this.

Use ellipsize property of textView as follows
<TextView
android:id="#+id/mywidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:lines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ff4500"
android:text="Simple application that shows how to use marquee, with a long text"/>

Related

How to make Google Play like TextView animation when text is too long?

In Google Play when the name of a certain title is too long then they apply an animation on this TextView when the name is going out from one end of the TextView, goes in from the other end, stops for a second on the beginning of the Title text, and then goes for the next round.
Does anyone have any explanation how can this be achieved?
This was what worked for me, you have to actually request for focus in order for the marquee animation to work:
<TextView
android:id="#+id/tvAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tvName"
android:layout_toLeftOf="#+id/ivLogo"
android:text=""
android:textColor="#color/cups_white"
android:textSize="18sp"
android:ellipsize="marquee"
android:singleLine="true"
android:marqueeRepeatLimit ="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true">
<requestFocus
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true" />
</TextView>
In your xml file where the TextView is declared you can use the following attributes:
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
with the singleline you going sure thats the Text is showend only in one line.
For more details look at this: http://developer.android.com/reference/android/widget/TextView.html

Text Animation in android

I want to animate the text of the textview not the whole textview in Android application. I am currently using Marquee property of Android textview but it is not 100% what i want, so i want to animate the text inside the textView so i can handle the events also. If someone with work around on this, please share your answers.
thanks
Here is what i have done at the moment using Marquee
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:duplicateParentState="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="bottom"
android:maxLines="1"
android:scrollbars="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Hello World"
android:textColor="#FFFFFF"
android:textSize="24sp"/>

Scrolling text view like a marquee in html

Hi i need to add a continuously scrolling text view to my app.
I need to update the text from a website .
Can anyone tell me any tutorials where i can find the code to do it.
Thanks for your help in advance.
Use this:
<TextView
android:id="#+id/textId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Simple application that shows how to use marquee, with a long text"
android:textColor="#ff4500" />
In Activity :
tv = (TextView) findViewById(R.id.textId);
tv.setSelected(true);
Thanks.

Android: TextView is not scrolling Automatically

I have a TextView with following attributes :
<TextView
android:id="#+id/appheader"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:layout_marginLeft="3dp"
android:textSize="21sp"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"/>
Actually the TextView scrolls ONLY when I click the TextView. But I want to scroll it automatically when I launch the Activity. How can I do this ?
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="very long text to srollll dkfjadkfjkldjfkjdkghjhtudhfjhdjfkdfkadjsajekdfjak"
android:singleLine="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"/>
By-default TextView marquee effect works when it get focus. To make an automatic marquee effect you need to extend TextView class. See this link for reference.
set android:scrollHorizontally="true" for that textview.
Also set the following two properties:
text.setMovementMethod(new ScrollingMovementMethod());
text.setSelected(true);

How to animate Text view like marquee?

I have a text view i need to marquee those along the screen(like the flash news flashing on news channels) using animation.now how can i implement this in android i tried this answer
but did not get the solution please help?
main.xml
<TextView
android:id="#+id/mywidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:lines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ff4500"
android:text="Simple application that shows how to use marquee, with a long text"
/>
java Class
TextView tv = (TextView) this.findViewById(R.id.mywidget);
tv.setSelected(true); // Set focus to the textview

Categories

Resources