Android开发之自定义Toast(吐司)

先看下效果一目了然:

Android开发之自定义Toast(吐司)_第1张图片

直接上代码

 Toast toast = Toast.makeText(getApplicationContext(), "带图片的Toast", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            LinearLayout toastView = (LinearLayout) toast.getView();
            ImageView imageCodeProject = new ImageView(getApplicationContext());
            imageCodeProject.setImageResource(R.mipmap.duigou);
            toastView.addView(imageCodeProject, 0);
            toast.show();

请看博主链接:博主直达

你可能感兴趣的:(Android总结)