3

I am trying to implement marquee a style to print string in android. I'm able to to it with static data but for dynamic it isn't displaying the marquee style.

When I print:

String st="this is test application testing for marquee"

I get the marquee style.

However, after parsing when I'm getting data:

<TextView
        android:id="@+id/twxmorq"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:ellipsize="marquee"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:padding="5dip"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:textColor="#FF0000" />

I run:

myString = myString + "| "+ json_data.getString("news_title").toString();

txt1 = (TextView) findViewById(R.id.twxmorq);
txt1.setText(myString1);

and I don't get the marquee style when I print mystring.

Please help me.

Summary: For the string ' ST ' I'm getting a marquee style printed string but for mystring1 I am not getting marequee style.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
Anil
  • 83
  • 3
  • 8
  • @TomR Sorry, I accidentally rejected your edit. Apparently if you say "Improve" in the review interface, then cancel, the edit is rejected and you can't undo that or check it. Sorry. However, if you're going to edit for grammar and readability, please try to be more comprehensive, not just make a few changes here and there. – Craig Ringer Aug 20 '12 at 06:42
  • is this your need http://stackoverflow.com/questions/2182578/marquee-text-in-android – J.K Aug 20 '12 at 06:45
  • Why Cant You Search Even in Google..?? – J.K Aug 20 '12 at 06:46
  • Thanx jenuine i got solution i was missing one line Thanx – Anil Aug 20 '12 at 06:49
  • where is myString1 initialize – Shalini Aug 20 '12 at 06:49
  • Shalini can u plz tell me how continue moving string when useother function of application – Anil Aug 20 '12 at 07:03

1 Answers1

1

Use below code for that.

<TextView
    android:id="@+id/twxmorq"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginTop="5dp"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:padding="5dip"
    android:scrollHorizontally="true"
    android:singleLine="true"
    ndroid:lines="1"
    android:textColor="#FF0000" 
    android:fadingEdge="horizontal"/>

Java Code:-

myString = myString + "| "+ json_data.getString("news_title").toString();

txt1 = (TextView) findViewById(R.id.twxmorq);
txt1.setSelected(true);
txt1.setText(myString1);
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128