直播网站源码Android自定义吐司显示效果

  

  

  

  

        <>以前public  class  ToastUtils  {   ,,,private  static  Toast  mToast;   ,,,public  static  void  showShortText (String 文本){   ,,,,,,,showText(文本、Toast.LENGTH_SHORT);   ,,,}   ,,,public  static  void  showLongText (String 文本){   ,,,,,,,showText(文本、Toast.LENGTH_LONG);   ,,,}   ,,,public  static  void  showText (String 文本,int 持续时间){   ,,,,,,,if  (TextUtils.isEmpty(文本)){   ,,,,,,,,,,,返回;   ,,,,,,,}   ,,,,,,,TextView  tvText;   ,,,,,,,if  (mToast ==, null) {   ,,,,,,,,,,,mToast =, Toast.makeText (MyApplication.getContext (),,,,,, Toast.LENGTH_SHORT);   ,,,,,,,,,,,final  View  toastLayout =, ((LayoutInflater), MyApplication.getContext () .getSystemService (Context.LAYOUT_INFLATER_SERVICE))   ,,,,,,,,,,,,,,,,,,,.inflate (R.layout.toast_layout, null);   ,,,,,,,,,,,tvText =, toastLayout.findViewById (R.id.toast_text);   ,,,,,,,,,,,mToast.setView (toastLayout);   ,,,,,,,}else  {   ,,,,,,,,,,,mToast.cancel ();   ,,,,,,,,,,,mToast =, Toast.makeText (MyApplication.getContext (),,,,,, Toast.LENGTH_SHORT);   ,,,,,,,,,,,final  View  toastLayout =, ((LayoutInflater), MyApplication.getContext () .getSystemService (Context.LAYOUT_INFLATER_SERVICE))   ,,,,,,,,,,,,,,,,,,,.inflate (R.layout.toast_layout, null);   ,,,,,,,,,,,tvText =, toastLayout.findViewById (R.id.toast_text);   ,,,,,,,,,,,mToast.setView (toastLayout);   ,,,,,,,}   ,,,,,,,mToast.setDuration(持续时间);   ,,,,,,,tvText.setText(文本);   ,,,,,,,mToast.show ();   ,,,}   ,,,,   ,,,//,普通方法.....   ,,,public  static  void  showToast (String 味精,int 持续时间),{   ,,,,,,,   ,,,,,,,mToast =, Toast.makeText (MyApplication.getContext(),,,,,,时间);   ,,,,,,,mToast.setText(味精);   ,,,,,,,mToast.show ();   ,,,}   }   ' ' '   * * toast_layout.xml * *   “‘clike   & lt; ? xml  version=?.0“,编码=皍tf-8" ?比;   & lt; LinearLayout  xmlns: android=癶ttp://schemas.android.com/apk/res/android"   ,,,xmlns:工具=癶ttp://schemas.android.com/tools"   ,,,android: id=癅 + id/toast_root"   ,,,android: layout_width=皐rap_content"   ,,,android: layout_height=皐rap_content"   ,,,android:背景=癅drawable/bg_toast"比;   ,,,& lt; TextView   ,,,,,,,android: textSize=?3.5 sp"   ,,,,,,,android:输入textColor=癅color/white"   ,,,,,,,android: paddingLeft=?2 dp"   ,,,,,,,android: paddingRight=?2 dp"   ,,,,,,,android: paddingTop=? dp"   ,,,,,,,android: paddingBottom=? dp"   ,,,,,,,android: id=癅 + id/toast_text"   ,,,,,,,android: layout_gravity=癱enter_horizontal"   ,,,,,,,android: shadowColor=? BB000000"   ,,,,,,,android: shadowRadius=?.75”;   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

直播网站源码Android自定义吐司显示效果