如何让Android中的文字从左向右移动?

Ham*_*azi 6 android textview

我使用此代码使文本移动,并从右向左正确移动.

不过,我想让TextView中的文本从左向右移动.

这是我目前的代码:

<TextView
    android:id="@+id/mylinenews"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="5"
    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:singleLine="true"

    android:text="textmoving textmoving textmoving textmoving textmoving textmoving textmoving textmoving textmoving textmoving "
    android:textColor="#fff"
/>
Run Code Online (Sandbox Code Playgroud)

如何修改此代码以使文本从左向右移动?

The*_*der 4

在 res 下的 anim 文件夹中使用以下 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

   <translate
        android:fromXDelta="-3%p"
        android:toXDelta="3%p"
        android:duration="1200" />
</set>
Run Code Online (Sandbox Code Playgroud)

并且,只需将其添加到您的 textview 中:

yourTextView.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move));
Run Code Online (Sandbox Code Playgroud)