2

I have this simple code that brings me a toast with an image. Is it possible to have the background that the regular toast uses on this toast?

Thx in advance

        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();
akuzma
  • 1,592
  • 6
  • 22
  • 49
alexandre
  • 63
  • 3

2 Answers2

1

You have to create a full custom layout as is mentioned here

Jordi Coscolla
  • 1,066
  • 6
  • 8
0

Check this questions:
Adding image to Toast?
Toast background changing to match Activity's Theme
Also it's good idea to check that:
http://www.cmwmobile.com/index.php?option=com_content&view=article&id=6&Itemid=40

Community
  • 1
  • 1
akuzma
  • 1,592
  • 6
  • 22
  • 49