marquee text view animation - android

The marquee animation does not work, this is what I did.
<LinearLayout android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/bg_trans"
android:layout_alignParentBottom="true" android:orientation="vertical">
<TextView android:id="#+id/trackName"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:textColor="#android:color/white" android:textSize="18sp"
android:maxLines="2" android:ellipsize="marquee"
android:scrollHorizontally="true"
android:focusable="true" android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:layout_gravity="center_horizontal" />
<TextView android:id="#+id/artistName"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:textColor="#android:color/white" android:textSize="18sp"
android:maxLines="2" android:ellipsize="marquee"
android:scrollHorizontally="true"
android:focusable="true" android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:layout_gravity="center_horizontal" />
</LinearLayout>
It works for the first textview but doens't work for the second. What am I doing wrong?

This works for me -
<TextView
android:id="#+id/capture_mode"
android:layout_width="200px"
android:layout_height="wrap_content"
android:text="This is a test of marquee on the text view in android."
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
/>
The field marqueeRepeatLimit will set the number of repitions.
UPDATE: The width of the text view need to be hardcoded to a specific value, you can set it to wrap_content. In such cases the marquee will still work just that it will have some blank space after the end the text and before it starts to display the text again. (Think Digital signboards, they have some gap in the display before displaying the next item.)

Other then what is mentioned above you also need to add
txtView.setSelected(true)
worked for me adding this line

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

Ellipsized TextView in ListView item not working

I've got an xml file for a ListView item. it looks like this, containing three textviews:
Now, the second TextView in the middle sometimes got text that is too long to fit between the other two TextViews. That's why I wanted to make it ellipsized.
My .xml file looks like this:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="1dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="2dp"
android:background="#drawable/card_background" >
<TextView
android:id="#+id/list_textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="#string/test"
android:textColor="#color/text"
android:textSize="20sp"
android:textStyle="bold"
android:width="75dp" />
<TextView
android:id="#+id/list_textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:layout_toRightOf="#+id/list_textview1"
android:layout_toLeftOf="#+id/list_textview3"
android:text="#string/test"
android:textColor="#color/text"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/list_textview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingLeft="20dp"
android:paddingRight="5dp"
android:text="#string/test"
android:textColor="#DEDEDE"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
As You might see in the center TextView values, I've added
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
But the result is just a long text, shorten with three points at the end. It just won't move?
Here's an image:
This center TextView does not scroll.
Note that it's an item of a ListView. That's why I tried to made the center TextView focusable, what ended in not being able to press on the list item.
Any ideas?
I've got the solution from user zgc7009 :
I just had to add:
TextView textView3 = (TextView) findViewById(R.id.list_textview3);
textView3.setSelected(true);
Worked nicely, thanks!

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

Determine which textview should be cut off

In a relativelayout I am using the code below. If the total width is too high tvProgress should be cut off. The problem is that I don't know how to determine which view should be cut off. The current code lets list_lib_episodes_watched_total cut off. How can I determine that tvProgress is cut off instead?
...
<TextView
android:id="#+id/tvProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/list_lib_et_episodes_watched"
android:layout_toRightOf="#+id/list_lib_cover"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:singleLine="true"
android:text="Progress:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/list_lib_et_episodes_watched"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/list_lib_status_spinner"
android:layout_toRightOf="#+id/tvProgress"
android:hint="0"
android:imeOptions="actionSend"
android:inputType="number"
android:maxEms="4"
android:maxLength="4"
android:text="0" />
<TextView
android:id="#+id/list_lib_episodes_watched_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/list_lib_et_episodes_watched"
android:layout_toLeftOf="#+id/list_lib_episodes_watched_increase"
android:layout_toRightOf="#+id/list_lib_et_episodes_watched"
android:lines="1"
android:singleLine="true"
android:text="/0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#707070" />
<ImageButton
android:id="#+id/list_lib_episodes_watched_increase"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/list_lib_et_episodes_watched"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/list_lib_et_episodes_watched"
android:layout_marginLeft="6dp"
android:layout_marginRight="8dp"
android:adjustViewBounds="true"
android:background="#drawable/btn_transparant"
android:contentDescription="Increase by 1"
android:minWidth="60dp"
android:scaleType="centerInside"
android:src="#drawable/ic_increase" />
...
Why cut any view?? It is wrap_content so you cannot determine like that. Put everything inside . Then nothing will be cut. You can scroll and see everything.
ScrollView is like this:
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
---
---
---
</ScrollView>

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