1.
public class ShowToast
{
public static void show(Context context, String content)
{
View toastRoot = ((Activity) context).getLayoutInflater().inflate(R.layout.toast, null);
Toast toast=new Toast(context.getApplicationContext());
toast.setView(toastRoot);
TextView tv=(TextView)toastRoot.findViewById(R.id.my_toast);
tv.setText(content);
toast.setGravity(Gravity.NO_GRAVITY, 0, 100);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
}
}
2.toast.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/my_toast"
android:layout_width="220dip"
android:layout_height="80dip"
android:textColor="#ffffff"
android:textSize="17dip"
android:gravity="center"
android:background="#33b5e5"/>
</LinearLayout>