如何使用选取框从左向右滑动文本

问题描述 投票:1回答:1

我正在使用选取框。在我的Android应用中,说pf文本视图的原始值是aaabbbccc及其在视图内的大小。因此,我的字幕输出为:aaabbbccc自动从右向左滑动。但是相反,我要将此aaabbbccc自动滑动从左向右滑动。我该怎么做...。下面是我的xml文件。谢谢`

            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" />`
android-studio textview ellipsize
1个回答
0
投票

默认系统从右向左滚动。使用动画从左到右滚动。

        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);

通过将400更改为任何其他值来调整屏幕区域的大小,并将持续时间更改为所需的时间。

© www.soinside.com 2019 - 2024. All rights reserved.