烤面包有图象背景

时间:2011-11-20 22:03:00

标签: java android

我有这个简单的代码,它带给我一个图像的祝酒词。是否可以获得常规吐司在此吐司上使用的背景?

提前谢谢

        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();

2 个答案:

答案 0 :(得分:1)

您必须按照here

提及创建完整的自定义布局

答案 1 :(得分:0)