How to animate Text view like marquee? - android

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

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

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.

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"/>

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

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