How to reverse the direction of marquee of a TextView

前端 未结 8 937
孤城傲影
孤城傲影 2020-11-30 05:16

I want to reverse the direction of marquee in the TextView. By default, the text moves from Right to Left, I want it to move from Left to Right. How can I do this?

相关标签:
8条回答
  • 2020-11-30 05:57

    Finally I found the BEST Solution here: https://github.com/Torob/MarqueeView

    to use this library:

    1. simply add this java file (MarqueeView.java) to your project java folder
    2. in your xml layout put your TextView inside of this MarqueeView like this:

        <your.packagename.MarqueeView
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:id="@+id/horizontalScrollView"
             android:scrollbars="none"
             android:visibility="visible"
             android:clickable="false"> 
         <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/test"
              android:id="@+id/scrollingtext"
              android:singleLine="true"
              android:focusable="false"
              android:focusableInTouchMode="false"
              android:paddingRight="25dp"
              android:paddingLeft="25dp" />
         </your.packagename.MarqueeView>
      
    0 讨论(0)
  • 2020-11-30 05:58

    Another simple way is using HTML and also you can change direction easily direction="Left"

    <html><body><FONT COLOR="#000000" ><marquee id="mrqSlogan"  direction="Left" style="width: auto;" >text your</marquee></FONT></body></html>
    

    And Pass to WebView

    webView.loadDataWithBaseURL(null, yourhtmltext, "text/html" , null, null);
    
    0 讨论(0)
提交回复
热议问题