Я хочу анимировать последние три точки в тексте
в части XML, у меня есть одно Textview, значение которого "настраивает ваш аккаунт ...".
поэтому я хочу просто анимировать последние три точки этого текста, когда пользователь нажимает «показать».
Я приложил gif с этим вопросом, чтобы вы могли получить представление о том, как я хочу анимировать эти точки в тексте
анимация gif
Я хочу сделать это с помощью ValueAnimator и java, а не Kotlin.
это часть XML моего кода
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main3Activity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="628dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.795"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="168dp"
android:text="setting up your account..."
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.351"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Mainactivtiy
public class Main3Activity extends AppCompatActivity {
private static final String TAG = "main3Activity";
private TextView vt;
private ValueAnimator animation;
private Button btnshow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
vt = findViewById(R.id.textView);
btnshow = findViewById(R.id.button);
final Spannable spannable = new SpannableString("setting up your account...");
String i = "setting up your account...";
Log.d(TAG, "onCreate: "+i.length());
final ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.WHITE);
//use Color.white beacuse i want to first dot to transparent when second one is displaying so and so
animation = ValueAnimator.ofInt(0,4);
animation.setRepeatCount(10);
animation.setDuration(1000);
animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int dotscount = (int)animation.getAnimatedValue();
if(dotscount<4){
spannable.setSpan(foregroundColorSpan,23+dotscount,26, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
vt.invalidate();
}
}
});
btnshow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animation.start();
}
});
}
}