Home>

Effect picture:

Code:

//toast for custom layout
customviewtoast.setonclicklistener (new view.onclicklistener () {
  @override
  public void onclick (view v) {
    toast toast=toast.maketext (toasttest.this, "top", toast.length_short);
    //Use only one textview here, of course, you can also use more complex views
    textview tv=new textview (toasttest.this);
    tv.settext ("customview toast.");
    tv.settextsize (typedvalue.complex_unit_dip, 20);
    tv.setcompounddrawableswithintrinsicbounds (r.drawable.abc_ic_menu_share_mtrl_alpha, 0, 0, 0);
    tv.setbackgroundcolor (color.parsecolor ("#ff88ff"));
    tv.setpadding (30, 10, 30, 10);
    tv.setgravity (gravity.center_vertical);
    toast.setview (tv);
    toast.show ();
  }
});
  • Previous Dynamically adding data to a table in JavaScript
  • Next PHP configuration background login and template introduction
  • Trends