Scrolling text view like a marquee in html - android

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.

Related

Marquee text is no working properly in samsung Galaxy S3

I have done a marquee text. I did this by the following code snippet
<TextView
android:id="#+id/scrolltext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:padding="5dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/scrolltext"
android:textColor="#F4CE6B" />
Problem is that it is not working properly in some phones like samsung Galaxy s3. The complete text is not displayed. Instead of that only few dotes are there.
Solved the issue.
I made a mistake in my coding by calling an additional scrolling movement method.
scroll_text.setText(scroll);
scroll_text.setSelected(true);
scroll_text.setMovementMethod(new ScrollingMovementMethod());
Now it seems to be ok by removing that line of code.
scroll_text. set Selected(true);
scroll_text.setText(scroll);
<TextView
android:id="#+id/scrolltext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
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="#F4CE6B" />
This worked for me.also give this in your activity's onCreate()
TextView textView = (TextView) findViewById(R.id.scrolltext);
textView.setSelected(true);

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

Scroll TextView like Marquee in 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"/>

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

Marquee in android

In my android application i need to scroll a marquee text continuously.
in my Xml i have this code:
<TextView
android:id="#+id/widget28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:singleLine="true"
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 RelativeLayout " />
And in my Java source code i have:
TextView tv = (TextView )findViewById(R.id.widget28);
tv.setSelected(true);
Now my issue is this code works fine and marquee runs fine even if the focus is not on the control but the scrolling of text is not complete.I need the text to scroll completely.If i add space to the text both before and after the text it works fine but that is not good programming. Is there a good way to this?
If you want it to scroll continuously, you must use this in your xml:
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:selectAllOnFocus="true"
android:singleLine="true"
It is not necessary to put setSelected(true); in the file
PS. You must only click on it when the focus changes.
try this::
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:singleLine="true"
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 RelativeLayout "
android:focusable="true"
android:focusableInTouchMode="true" android:freezesText="true"></TextView>
Guys, TextView scrolls its text ONLY when it's focused. As soon as it loses the focus, text scrolling will stop.
I don't understand your issue.
I have copied your code and inserted the TextView in a RelativeLayout with fill_parent for the 2 axes and it works fine (isn't that what you want?) :
I have tested that code on default emulator 2.1 and 2.2. No trouble.
Here is my class :
public class TextViewMarquee extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.textview);
findViewById(R.id.widget28).setSelected(true);
}
}
And the associated xml :
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/widget28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Simple application that shows how to use RelativeLayout"
android:textColor="#ff4500" />
</RelativeLayout>
And that's actually all, no mystery line in the manifest or style or ...

Categories

Resources