Android Widget: Textview stops marquee on homepage scroll - android

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)

Related

How to make vertical scrolling textview's in Android

I have been looking for a post to create vertical scrolling multiple textviews. similar to one shown here http://vertical-scroller.vbarsan.com/
But all post are related to creating horizontal scrolling (Marquee) textview.
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"/>
I hope this helps
Have main layout as ScrollView ,Create vertical LinearLayout as child of ScrollView and create (number of textview you required ) textViews inside LinearLayout.
you should change android:layout_height
as per your code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#FF4081"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="1st Line !" />
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="2nd line !"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="3rd line !" />
</LinearLayout>
</ScrollView>
You have 2 choice for that:
1) Use Native way: using thread, put 10 spaces before any text and in each second remove left side space and increase right space and so on, until it's limits. Hope you understood. Predefined TextView's below properties also uses this method.
2) Use predefined control TextView with below properties:
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
use this example code below it will do a marquee like html
<TextView
android:id="#+id/mywidget"
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 marquee, with a long text" />

Scrolling textview is not scrolling, in Android.

I'm making my text scrolling as the post here.
I think I saw it was scrolling first time in another layout even without any java code.
But now, it's not scrolling anymore. No idea what's wrong with this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
<LinearLayout
android:id="#+id/scrollingTextLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#0792B5"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/scrollingText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:maxLines="1"
android:padding="5dp"
android:scrollHorizontally="true"
android:text="The culture of India is the way of living of people of India."
android:textColor="#FFFFFF"
android:textSize="16sp" />
</LinearLayout>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/scrollingTextLayout"
android:background="#android:color/darker_gray" />
</RelativeLayout>
just put these lines in your xml:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:scrollHorizontally="true"
And in your code:
textView.setSelected(true);
It's now scrolling. I just changed maxLines="1" to singleLine="true" , you know it's a little weird. I changed singleLine to maxLines because the IDE suggested me to use maxLines instead of singleLine since it's deprecated already.
Add this code in Activity
TexView tv=findViewbyId(R.id.scrollingText);
tv.setSelected(true);

ScrollView kills my android app, and I don't understand something about the table view

I'm writing a small application for my nexus 7 tablet, and I have a strange error. To my understanding the following xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<ScrollView>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="name"
android:inputType="text"
android:textSize="20sp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="smells more like prey than a hunter."/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="The spirits spoke to me of a great danger that follows"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="name"
android:inputType="text"
android:textSize="20sp"/>
</TableRow>
</ScrollView>
</TableLayout>
should produce a scrollable app with two lines, each with a text field with gray name written in it, with the text wrap around it and additional text that will be written before or after the text that will try and fill the screen. When I compile this, however, the application crash (unfortunately, has stopped). If I remove the ScrollView attribute, The two lines are of the same length, with the EditText taking half the space on each line while in landscape mode. In portrait mode, the first line holds only the EditText field and the second one only the TextView field. It seams to me that the table tries to fit the two lines into the same length, but I can't understand why.
How can I fix this?
Comment:
I'm using a library structure generate by aide, which I use only to compile my code on the tablet.
put your table layout all inside the scrollview. scrollview can onlyhost one direct child, but that child can have many children! also you still need a height and width for scrollview
here
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="name"
android:inputType="text"
android:textSize="20sp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="20sp"
android:text="smells more like prey than a hunter."/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="name"
android:inputType="text"
android:textSize="20sp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:text="The spirits spoke to me of a great danger that follows"/>
</LinearLayout>
</TableLayout>
</ScrollView>
should work for u.
try the above layout instead of yours and let me know if it helps. to tell the truth i think you want a listview and an adapter...

How to add marquee effect to listview?

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>

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