问题
Marquee is not scrolling whole text or it is repeating in every second Hello, I am scrolling text using marquee. but it is scrolling for only one seconds and it is not scrolling whole text. Please suggest me. Here is my code of textview : `
android:gravity="center_vertical"
android:layout_alignParentBottom="true"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:id="@+id/ticker1"
android:textColor="#FFF"
android:textSize="20sp"
android:textStyle="bold"
android:text=""
android:layout_gravity="center_vertical"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
/>
</LinearLayout>`
回答1:
You probably have some code taking off the focus of your TextView. I've tried something like that to replicate your problem, and it works.
myTextView.setSelected(true);
Runnable r = new Runnable() {
@Override
public void run(){
myTextView.setSelected(false);
}
};
Handler h = new Handler();
h.postDelayed(r, 5000);
This stop the text scrolling for 5 seconds after its begin. Search in your code for something that can do something like this.
回答2:
yes
we need to initialise textview and make it as
textview.setSeletced(true);
for more detailed tutorial
Click here!
来源:https://stackoverflow.com/questions/37518951/marquee-not-scrolling-whole-text-in-android