android-studiotextviewellipsize

How to slide Text from left to right using marquee


I am using marquee.In my Android app Say original value pf text view is aaabbbccc and its fitting inside the view. So my marquee's output will be : aaabbbccc auto sliding from right to left. But instead of this i want to slide this aaabbbccc auto sliding from left to right. How can i do this....Below is my xml file.Thanks`

            android:id="@+id/txt_MainScreen_Winnerlist"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="-10dp"
            android:layout_marginTop="0dp"
            android:layout_marginRight="20dp"
            android:ellipsize="marquee"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:fontFamily="@font/proximanovaregular"
            android:gravity="center"
            android:marqueeRepeatLimit="marquee_forever"
            android:paddingTop="2dp"
            android:paddingRight="25dp"
            android:scrollHorizontally="true"
            android:singleLine="true"
            android:text="Exchange1:(00.14-2.30) Exchange2:(01.00-2.30) Exchange3:(05.00-6.30) Exchange4:(12.14-2.30) Exchange5:(10.00-12.30) Exchange6:(00.30-2.30) Exchange7:(03.00-05.00) "
            android:textSize="13dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent" />`

Solution

  • Default system scrolls from right to left. Use animation for left to right scroll.

            Animation animationl2r = new TranslateAnimation(-400,400, 0, 0);
            animationl2r.setDuration(12000);
            animationl2r.setRepeatMode(Animation.RESTART);
            animationl2r.setRepeatCount(Animation.INFINITE);
            TextView textview = findViewById(R.id.textview);
            textview.setAnimation(animationl2r);
    

    Resize the screen area by changing 400 to any other value and duration to your desired time.