I am displaying a toast in my screen, but the position of the toast appears to vary from device to device, i want the toast to be displayed at one particular position for all the screen sizes.Please help me out with this.
Thanks!
First you need to get the screen dimensions.
Use them to calculate the toast's position, and place it in the appropriate position.
For any one if facing this same problem would suggest you to try this out
IMP is that you are not in the activity class
WindowManager wm = (WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width=size.x;
int height=size.y;
where appcontext is ur own appcontext.
but if you are in the activity class you can use this
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
You may create a custom Toast message with a custom xml layout. Refer this example on Android Developers.