我使用此代码使文本移动,并从右向左正确移动.
不过,我想让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)
如何修改此代码以使文本从左向右移动?
在 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)
| 归档时间: |
|
| 查看次数: |
21981 次 |
| 最近记录: |