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

Download, Install & Use Angry Birds Journey on PC (Windows & Mac)

Angry Birds Journey is a new edition of one of the most…

Adding Users to the Local Admin Group via Group Policy

You can use Group Policy to add Active Directory users and groups…

Download HitFilm Express For Windows PC/Laptop & Mac

Hey there! Before reading the article which is about Download HitFilm Express…

How To Get Cash From Prepaid Visa Debit Card

When you apply for a prepaid debit card you could be asking…