There are two methods.
Method 1
SpannableStringBuilder builder = new SpannableStringBuilder(); SpannableString redSpannable= new SpannableString(appdata); redSpannable.setSpan(new ForegroundColorSpan(Color.RED), 0, appdata.length(), 0); builder.append(redSpannable);
Method 2
appdata_in_red = Html.fromHtml("<font color=#ff0000>" + appdate + "</font>");
I took the simplest method, and I included it in my code as follows:
String appdata = "%" + txtFromSpinner + location.getText() + "%" + date.getText()+ "%" + start.getText() + "%" + finish.getText() + "%" + lunch.getText() + "%" + details.getText(); Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{" payrolldirectgib@gmail.com "}); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Timesheet/Parte de horas"); //this line below emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<font color=#ff0000>" + appdata + "</font>") +sep+ "Please send this email."+sep+ "Your timesheet details are included in it."+sep+ "Thank you."+sep+ "Regards,"+sep+ "Admin Department."+sep+ "Payroll Direct."); emailIntent.setType("message/rfc822"); startActivity(emailIntent);
Hope my answer helps you.
source share