Android自定义Toast样式
public class ToastUtils {    private static Toast toast;    private static TextView textView;    public static void showToast(Context context, String text) {        if (toast == null) {            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);            View view = inflater.inflate(R.layout.item_toast_bg, null);            textView = (TextView) view.findViewById(R.id.tv_toast_text);            textView.getLayoutParams().width = Utils.getWindowWidth(context);            toast = new Toast(context);            toast.setGravity(Gravity.BOTTOM, 0, 0);//如果不设置剧中方式,使用系统默认的吐司位置            toast.setDuration(Toast.LENGTH_SHORT);            toast.setView(view);        }        textView.setText(text);        toast.show();    }}  

更多相关文章

  1. Android(安卓)封装实现各种样式对话框
  2. Android中吐司当前电池电量
  3. Android(安卓)自定义CheckBox 样式
  4. 关于Android中的各种Dialog
  5. Android(安卓)单选组合框
  6. 我的android 第三天 - 自定义Toast
  7. Android五种Toast显示样式
  8. Android(安卓)Studio常用对话框
  9. 面试官:作为Android高级攻城狮,请你解释一下 android:text 到 Text

随机推荐

  1. Android原生集成MUI框架进行混合开发
  2. Android 内存溢出和内存泄漏的区别
  3. androidの获取天气预报JSON 实现
  4. Windows环境下Android NDK的开发
  5. 实例9---我的地图
  6. Android(安卓)Studio 的四种打包方式
  7. Android(安卓)网络防火墙的实现 Iptables
  8. Android之Toast自定义管理
  9. Android(安卓)开发中的架构模式 -- MVC /
  10. android toast乱码