1. Everything Android is a community forum that makes it easy to ask questions about anything and everything Android. It's 100% free and no registration required (though we think it would be awesome if you joined our community). Our community of experts are here to help.
    Dismiss Notice

Customizing A Toast

Discussion in 'Android Questions' started by kamlesh yadav, Jun 4, 2013.

  1. kamlesh yadav

    kamlesh yadav New Member

    Mar 12, 2012
    0

    Sponsored Ad

    In Android we can customize the Toast and can change Color, Size, Position etc.
    Read the full Post How to Customize Toast

    //create a LinearLayout and Views

    LinearLayout layout=new LinearLayout(this);
    layout.setBackgroundResource(R.color.LightOrange);

    TextView tv=new TextView(this);
    // set the TextView properties like color, size etc
    tv.setTextColor(Color.RED);
    tv.setTextSize(15);

    tv.setGravity(Gravity.CENTER_VERTICAL);

    // set the text you want to show in Toast
    tv.setText("My Custom Toast at Bottom of Screen");

    ImageView img=new ImageView(this);

    // give the drawble resource for the ImageView
    img.setImageResource(R.drawable.myimage);


    // add both the Views TextView and ImageView in layout
    layout.addView(img);
    layout.addView(tv);

    Toast toast=new Toast(this); //context is object of Context write "this" if you are an Activity
    // Set The layout as Toast View
    toast.setView(layout);

    // Position you toast here toast position is 50 dp from bottom you can give any integral value
    toast.setGravity(Gravity.BOTTOM, 0, 50);
    toast.show();
     
  2. stevetaz

    Moderator

    Sep 23, 2008
    87
    Not sure if that is your site, but if it is I have to ask if the title is spelled the way it is for a reason?
    "
    Android Tutorials for Begginer

    "
    Begginer should be spelled Beginner......

    Sorry, can't help myself.....:eek:
     
  3. Sponsored Advertisement

Share This Page