MainActivity.java:


setContentView(R.layout.activity_main);

TextView textView = findViewById(R.id.tvid);
String text = "Your Text";

SpannableString ss = new SpannableString(text);

ForegroundColorSpan fcsMain = new ForegroundColorSpan(Color.rgb(58,
186,
186
));

ss.setSpan(fcsMain, 5, 9, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(ss);