[英]android animation textview rotate string left to right
我需要把textview里面的String從左到右動畫化,這樣當從右邊去掉文字時,就可以從左邊輸入了,如下圖。
上面的文字(Compute Sentence Probability)必須按如下動畫,從圖像中移除並在另一側輸入,如下圖所示。
我使用了下面的animation,但是在這個animation中,整個文本從右到左一次,再次它不會在文本離開另一側的同時輸入,直到整個文本才再次輸入文字出來了。
animation
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="6000"
android:fromXDelta="100%"
android:interpolator="@android:anim/linear_interpolator"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toXDelta="-100%" />
從TextView
和
在您的 xml 文件中添加 textview
<TextView
android:id="@+id/tvUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Computer Sentence Probability..........."
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
/>
在 java 文件中簡單添加這一行
TextView tvUsername = (TextView)findViewById(R.id.tvUsername);
tvUsername.setSelected(true);
此答案有效,如果您想從右到左支持可以將以下代碼添加到 xml 中的 TextView
android:textDirection="rtl"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.