Marquee not scrolling whole text in android

与世无争的帅哥 提交于 2019-12-25 18:14:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!