Monday, 7 January 2013

Custom Toast in Android

First Create New Android Project and after that add below xml file in res/layout folder and add below code into your file.


<LinearLayout xmlns:android=""
    android:background="#ffffff" >
    <ImageView android:id="@+id/image"
        android:layout_marginRight="10dp" />

    <TextView android:id="@+id/text"
        android:textColor="#FFF" />

Add below code into your file

LayoutInflater inflater = getLayoutInflater();

View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(;
ImageView image = (ImageView) layout.findViewById(;
TextView text = (TextView) layout.findViewById(;
text.setText("Hello! This is a custom toast!");
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);

Enjoy  :-)

Don’t forget to provide feedback or follow this blog, if you find this blog is useful.


  1. very very helpful for android developers. Visit Us :

  2. HI Dipak,Please send me android custom pdf viewer source code it will will helpfull for me

  3. following your Mobile Application I am very glad follow me on:-When it comes to profitability of business, recording the voice too becomes most vital. There are several types of voice logging system which will help you to get best results. You can use voice recorder software for some future references and voice logger software to get feedbacks from customers while you are not over phone to receive such calls. Here call logger software will help you a lot.