How to add marquee effect to listview? - android

I have list of my friends in ArrayList & i am trying to display it in listview using ArrayAdapter & rowlayout.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="#+id/rowlayout"
android:padding="10dp"
>
Now i want to add marquee effect to it.I want to scroll this listview forever.
For this i added following code
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:singleLine="true"
But this code stop my OnLongClickListner effect of listview.
I don't know why?

android:ellipsize="marquee"
android:gravity="left"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine is depricated,focusable -not needed too
This layout works in a new sample project:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:text="12312312321321312312321321312311321321321312321312312123132132132" />
</RelativeLayout>

Related

Horizontal scrollable Textview not working

This is the xml file for scroll the textview,but it is not working.
<TextView
android:id="#+id/txt_join_crew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingEnd="5dp"
android:paddingRight="5dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/join_my_crew"
android:textSize="#dimen/content_text_size" >
</TextView>
this is the xml code and it is not working.
You code work but you have add this code in java
TextView tv=(TextView)findViewById(R.id.txt_join_crew);
tv.setSelected(true);

Android App Widget - How To Create TextView Marquee On Two Separate Lines With Adjustable Scrolling Speeds?

I'm trying to create a widget with several different lines on it and want to set it to auto scroll (marquee) and have the ability to adjust the scrolling speed. How can I accomplish this?
I tried using a TextView and was able to make it scroll on one line, but that's it. I can't seem to adjust the speed of it or have two lines scrolling at the same time.
An example of this is: https://play.google.com/store/apps/details?id=huntsman.stocktickertapelite&hl=en
OR
https://play.google.com/store/apps/details?id=com.cousinHub.widget
Anyone have an idea of how they did it? (custom views?)
Thanks.
This is what I have so far:
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textStyle="bold"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/app_name"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true"
android:layout_weight="1">
<requestFocus
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true" />
</TextView>
Try this, I am getting the text from Java as setText file, and show in this screen
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/line_dotted"
android:layout_marginBottom="10dp"
android:fillViewport="true"
android:scrollbars="vertical" >
<TextView
android:id="#+id/text_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"
android:layout_marginTop="10sp"
android:scrollbars="vertical"
android:textColor="#0A2A1B"
android:textSize="12sp" />
</ScrollView>
Or You can try this without scrollview, the text will scroll when there is more than 5 ines
<EditText
android:id="#+id/Comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Submitbtn"
android:layout_alignParentLeft="true"
android:layout_below="#+id/ratingBar"
android:layout_marginBottom="40dp"
android:ems="10"
android:gravity="left"
android:hint="Comments"
android:maxLines="5"
android:padding="20dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:imeOptions="actionDone" />

Android Widget: Textview stops marquee on homepage scroll

I have a text view in my widget that scrolls the text like a marquee. Now, it works in normal state. But, if i scroll(swipe) through my home screen for other pages, then this textview stops scrolling. Any Idea how to solve this?
My xml file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="8dip"
android:background="#drawable/myshape" >
<TextView
android:id="#+id/update"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:textSize="25dp" >
<requestFocus
android:duplicateParentState="true"
android:focusable="true"
android:focusableInTouchMode="true" />
</TextView>
</LinearLayout>
Thanks.
Your xml looks ok,
in your resume method
try add
textview_update.setSelected(true);
also, I had found some small devices can't handle textview that has length over 1024 otherwise it will stop (when memory is full)

Android: ViewFlipper resetting my marquee TextView

My app contains a ViewFlipper and in the same activity, a marquee text inside a TextView.
The TextView is NOT inside the ViewFlipper. The ViewFlipper is filled programatically later.
When the Viewflipper transition occurs, the marquee text resets, returning to initial position...
Anyone knows why do this happen?
How can I fix that?
//VIEWFLIPPER
<ViewFlipper
android:id="#+id/vfHome"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:flipInterval="5000" >
</ViewFlipper>
//...
//MARQUEE TEXT
<TextView
android:id="#+id/tvHome"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:paddingTop="2dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:scrollHorizontally="true"
android:scrollbars="horizontal"
android:singleLine="true"
android:text=""
android:textColor="#EEE"
android:textSize="13dp" >
</TextView>
Thanks

marquee in Android

I want to marquee the textview but am not getting success to do it properly. Though i have gone through some examples give in stackoverflow, but still having problem. can anybody help?
try this it is working for me
<TextView
android:text="Android Marquee"
android:id="#+id/MarqueeText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true">
</TextView>
It is the minimum code to create a marque -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/MarqueeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="This is a very long text which is not fitting in the screen so it needs to be marqueed."
android:textAppearance="?android:attr/textAppearanceLarge" />
To make your marque more presentable view this:
http://yhisham.blogspot.in/2012/08/android-how-to-make-marquee-ticker.html

Categories

Resources