Today, there is a problem with the project, when the content of the toast is too long.
The system splits the content multiple lines and then displays on the left.
Obviously this is not very good for our visual effect.
How do you center it?
After you have checked the relevant documents, you can add the following code to toast when you are ready to toast.
or call the following method directly.
Public Static void Showtoastcenter (Context context, String toaststr) { = Toast.maketext (context.getapplicationcontext (), Toaststr, toast.length_short); int Tvtoastid = Resources.getsystem (). Getidentifier ("message", "id", "Android"); = ((TextView) Toast.getview (). Findviewbyid (Tvtoastid)); if NULL ) { tvtoast.setgravity (gravity.center); } Toast.show (); }
Of course you can also make a static variable toast, to add the code of the polygon, and then call, you can
Android toast content is too long, how to center display?