I do n’t know if all the guest officers find the system toast information ugly.The default but black background,No color.

Then I will teach you the simplest way to customize the toast layout.

First load a custom layout

layoutinflater inflater=context.getlayoutinflater ();
view view=inflater.inflate (r.layout.toast_info, null);

Then find the controls inside,Take pure textview as an example

textview txt=(textview) view.findviewbyid (r.id.txt_tips);

The next step is to set the information for the textview.

txt.settext (info);

The most important thing is the following,Reference layout toast

Get toast:

toast toast=new toast (context);

Set the toast display position:

toast.setgravity (gravity.center_horizontal | gravity.bottom, 0, 80);

Set the pop-up time:

toast.setduration (time);

Set the layout:

toast.setview (view);

last step,show it out:

toast.show ();

Dear! Isn't it simple?In the future, you can use the handsome toast information.Far from the dwarf,This is the goal of our struggle

  • Previous Failed to load file or assembly error when calling DLL in C # (detailed explanation)
  • Next Summary of common PHP sorting algorithm examples [basic sort, bubble sort, quick sort, insert sort]
  • Trends