Ioannis I
Ioannis I

Reputation: 308

Android toast has strange shape

When using toast messages in my app it appears in a wrong shape. The code I am using is:

Toast.makeText(context, context.getResources().getString(R.string.changeLanguageConf), Toast.LENGTH_SHORT).show();

Toast wrong shape

Do you know what could be the root cause? context is an argument passed as getContext() from a different procedure.

Upvotes: 1

Views: 224

Answers (2)

Ioannis I
Ioannis I

Reputation: 308

It was due to the theme used. More specific it was due to:

<item name="android:fitsSystemWindows">true</item>

Thanks for the help

Upvotes: 1

codemirel
codemirel

Reputation: 160

Instead of using getContext(), try using getApplicationContext(). I would also try to get the context just before creating and showing the toast, as the following.

Context context = getApplicationContext();
Toast.makeText(context, context.getResources().getString(R.string.changeLanguageConf), Toast.LENGTH_SHORT).show();

Upvotes: 0

Related Questions