I am using Toast.makeText to display results from dialogs and having a slightly odd problem: the text is displaying above the frame that should hold it, like this:
The message is misaligned with the frame. Please align it better. [_________________________________________________]
I'm generally using code looking like
Toast bread = Toast.makeText(getContext(), R.string.message, Toast.LENGTH_LONG);
bread.show();
from a dialog. I've heard bad context can sometimes cause inflation problems but getOwnerActivity()
is returning null, so that's out. In any case, I would have thought getContext() would supply the context passed in at construction time, which is the activity anyway.
Any suggestions?
you can try this:
Toast bread = Toast.makeText(getApplicationContext(), R.string.message, Toast.LENGTH_LONG);
bread.show();
bread.setGravity(5,5,5);
try playing around by changing those values till you get exact location.
But using Gravity.CENTER
and other constants is the prefererrd way..
If you create the toast from inside an activity you should use: this
or MyActivityName.this
as the context parameter.
Try using,
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" />
in your manifest file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With