tags:

views:

123

answers:

3

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?

A: 

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?) :
alt text

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

And that's actually all, no mystery line in the manifest or style or ...

Sephy
Hello SephyHow are you using RelativeLayout with fill_parent for the 2 axes.I am using the textview inside table layout and what i am getting is like it starts scrolling and stops once it reaches end of text like ,i will be able to see these text on screen application that shows how to use RelativeLayout and later again it starts from simple application.In short only Simple app is what gets disappeared and not the full text as shown by u.
Remmyabhavan
Could you please share your code with me?
Remmyabhavan
Ok, i'll post my code, but it's quite similar to yours.
Sephy
Thanks Sephy.I just want to have a look as where am i going wrong.Please post it.
Remmyabhavan
But it is not working for me Sephy.Any ideas or suggestions.
Remmyabhavan
That darn marquee feature never would work for me either. I think there's a marquee conspiracy
Brad Hein
Well, actually, I have no idea... I'll detail my config and code in my post so that you can compare with yours...
Sephy
Thanks Sephy.Yes its working fine in 2.1,2.2 but not in 1.5.I need it to work in 1.5.
Remmyabhavan
You should mention the system you are working with when you ask a question, that helps. Then I don't know why it's not working in 1.5 sorry
Sephy
I have tested quite a lot and coulnt find any way to make the text of the marquee run in a circular way in Android 1.5, this is strange.
Sephy
Sorry Sephy.Will remember to mention the system hereafter.Hmmm facing the same issue.
Remmyabhavan
A: 

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>
Jorgesys
Thanks Jorgesys.if we set focusable true,it works only if the control has focus.Instead remove focus and set selected as true then it works fine.It doesnot work in android 1.5 emulator.I am trying for that.
Remmyabhavan
Hi Reshmi, yes definitely it needs to have the focus to work, and it works on Android 1.5 Emulator too, install the latest SDK.
Jorgesys
A: 

Guys, TextView scrolls its text ONLY when it's focused. As soon as it loses the focus, text scrolling will stop.

Paul Turchenko
This is why we added .setSelected(true);
Sephy