1、自定义布局、居中显示
/**
* 中间显示自定义toast
*/
public static void showCustomToast(Context context, int layoutId) {
Toast toast = new Toast(context);
View view = LayoutInflater.from(context).inflate(layoutId, null);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(view);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
2、自定义Toast背景
<style name="CustomCommonToast">
<!--toast背景-->
<item name="legoCommonToast_background">@mipmap/bg_toast_small</item>
<!--多行背景-->
<item name="legoCommonToast_multiline_background">@mipmap/bg_toast_big</item>
</style>