Android: How to set the colour of a Toast’s text

You can achieve this very easily, without creating a custom layout by modifying the default Toast :

Toast toast = Toast.makeText(this, resId, Toast.LENGTH_SHORT);
TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
v.setTextColor(Color.RED);
toast.show();

You can find the layout used by the default toast view in the Android SDK :

$ANDROID-SDK$/platforms/android-8/data/res/layout/transient_notification.xml

Leave a Comment