I want to use the feature of marquee in my android app and am using this code for achieving the goal:
<TextView
android:id="@+id/marqueetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:text="hello all how are you"
android:textColor="#ff4500"
/>
MarqueeText = (TextView)ShowTheMessages.this.findViewById(R.id.marqueetext);
MarqueeText.setSelected(true);
I don't know why it is not working.I have gone through many related posts but have not found the solution.Please help me.Thanks in advance.
change this line and try...
android:text="hello all how are you hello all how are you hello all how are you hello all how are you"
TextView txtView=(TextView) findViewById(R.id.marqueetext);
txtView.setSelected(true);
<TextView
android:id="@+id/marqueetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:text="hello all how are you hello all how are you hello all how are you hello all how are you"
android:textColor="#ff4500"
/>
or another example is...
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/marqueetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:lines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ff4500"
android:text="hello all how are you hello all how are you hello all how are you hello all how are you hello all how are you" />
</RelativeLayout>
android:singleLine="true"
android:ellipsize="marquee"
are the only required attributes and scrolling even works with layout_weight
defined with layout_width=0dp
here is some sample code:
<TextView
android:id="@+id/scroller"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"
android:text="Some veryyyyy long text with all the characters that cannot fit in screen, it so sad :( that I will not scroll"
android:layout_marginLeft="4dp"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
/>
but the most important is TextView should get selected that you have already Done in your code.
hope it will help you out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With