我有这个简单的代码,使我为图像敬酒。是否有普通吐司在该吐司上使用的背景?
提前Thx
Toast ImageToast = new Toast(getBaseContext());
LinearLayout toastLayout = new LinearLayout(getBaseContext());
toastLayout.setOrientation(LinearLayout.HORIZONTAL);
ImageView image = new ImageView(getBaseContext());
TextView text = new TextView(getBaseContext());
image.setImageResource(R.drawable.smile);
text.setTextSize(30);
text.setText("Show this text");
toastLayout.addView(image);
toastLayout.addView(text);
ImageToast.setView(toastLayout);
ImageToast.setDuration(Toast.LENGTH_LONG);
ImageToast.show();
最佳答案
您必须创建完整的自定义布局,如here所述