Android 自定义Toast

Android 自定义Toast

效果:

代码:

    Toast toast = new Toast(MainActivity.this);
    toast.setDuration(Toast.LENGTH_LONG);

    LayoutInflater inflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.itemlayout, null);
    toast.setView(view);
    toast.show();

 

posted @ 2021-01-03 16:46  sunny开始学坏  阅读(291)  评论(0编辑  收藏  举报