public class ToastUtils { private ToastUtils() { /* cannot be instantiated */ throw new UnsupportedOperationException("cannot be instantiated"); } public static boolean isShow = true; /** * 短时间显示Toast * * @param context * @param message */ public static void showShort(Context context, CharSequence message) { if (isShow){ // Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); // 纯文本提示框 (居中) Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER,0,0); LinearLayout linearLayout = (LinearLayout) toast.getView(); TextView messageTextView = (TextView) linearLayout.getChildAt(0); messageTextView.setTextSize(25); messageTextView.setTextColor(Color.parseColor("#FFFFFF")); toast.show(); } } /** * 短时间显示Toast * * &
自定义toast工具类
最新推荐文章于 2024-07-04 09:24:51 发布