Development issue/problem:

I display the toast message as a result of the if declaration with the following code :

Toast.makeText(getBaseContext(), Enter the Price, Toast.LENGTH_SHORT).show() ;

It appears as a white text on a white background, so unreadable! My question is: how can I change the colour of the toast text?

How can I solve this problem?

Solution 1:

You can make your own kind of toast according to your needs. See Making a custom toast at

Solution 2:

You can do this very easily without creating your own layout by using the standard Toast:

ToastToast = Toast.makeText(dit, resId, Toast.LENGTH_SHORT);
TextView v = (TextView) toast.getView().findViewById(;
v.setTextColor(Color.RED); ;

The default presentation of the Toast view is in the Android SDK :


Solution 3:

You can make your own toast

LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout,
(ViewGroup) findViewById(

ImageView image = (ImageView) layout.findViewById(;
TextView text = (TextView) layout.findViewById(;
text.setText(Hello! This is your toast!)

Toast toast = new Toast(getApplicationContext()) ;
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0) ;
toast.setDuration(Toast.LENGTH_LONG) ;
toast.setView(layout) ; ;


Solution 4:

The easiest way to change the background colour of the toast and the background colour of the toast text:

TextView text;
toast.makeText(this, resId, Toast.LENGTH_SHORT);
view = toast.getView();
text = (TextView) view.findViewById(;
view.setBackgroundResource(R.color.white); ;

Solution No 5:

You can also use SpannableString. It can also color parts of a rope.

SpannableString spanableString = new SpannableString(This is red text);
new ForegroundColorSpan(getResources().getColor(android.R.color.holo_red_light))),
Toast.makeText(this, SpannableString, Toast.LENGTH_SHORT).show() ;

Solution No 6:

Try the Toasty Library. It is very easy to use –

Give here a description of the image

Solution No 7:

You can try this if you don’t want to use custom libraries.

Toast=Toast.makeText(getApplicationContext(),This is extended toast,Toast.LENGTH_LONG);
view textview1=(TextView)view.findViewById( ;
view1.setTextColor(Color.YELLOW) ;
view.setBackgroundResource(R.color.colorPrimary) ; ;

Solution No 8:

Here is an example in Kotlin that shows how to change the background colour of the toast and the colour of the text:

val toast = Toast.makeText(context, text, Toast.LENGTH_SHORT)toast.view.background.setColorFilter(ContextCompatible.getColor(context,R.color.white), PorterDuff.Mode.SRC_IN)fall textView = toast.view.findViewById( as TextViewtextView.setTextColor(ContextCompat.getColor(context,

Good luck!

android toast default background color,toast background,how to change toast text size in android,android toast style,custom toast in android,toast gravity,toast getview deprecated,android toast font color,android toast bold text,android toast theme,how to set toast size in android

You May Also Like

How can I fix the Spinner style for Android 4.x placed on top of the Toolbar –

Development issue/problem: According to the Android documentation, the material design style is…

How to fix corrupted system files in Windows 10 • [FULL GUIDE]

Sometimes an SFC scan can’t restore your files on Windows, but if…

VPN connection failed with error 691 in Windows 10 [FIX]

Error: The file name is not specified. Milan Stanojevic – deputy editor-in-chief…

How to Remove Fake Critical Chrome Update Scam

RECOMMENDED: Click here to fix Windows errors and optimize system performance. A…