сначала создайте массив цветов в XML-файле.
<array name="textViewColors">
<item>@color/bright_pink</item>
<item>@color/red</item>
<item>@color/orange</item>
<item>@color/yellow</item>
<item>@color/chartreuse</item>
<item>@color/green</item>
<item>@color/spring_green</item>
<item>@color/cyan</item>
<item>@color/azure</item>
<item>@color/blue</item>
<item>@color/violet</item>
<item>@color/magenta</item>
</array>
и создайте тему:
TextView textView;
//an array to access the color we declare in xml file
int[] textViewColors = context.getResources().getIntArray(R.array.textViewColors);
Thread changeColor = new Thread() {
@Override
public void run() {
try {
sleep(5000); //time that set interval. this is for 5 sec
runOnUiThread(new Runnable() {
@Override
public void run() {
for(int i=0;i<=textViewColors.size();i++){
textView.setTextColor(textViewColors[i]);
}
}
});
} catch (Exception e) {
}
}
};
и извините нить, где вы хотите. например в onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
---> changeColor.start();
}
Надеюсь, это будет полезно для вас.