总盯着过去,你会瞎掉一只眼;然而忘掉历史,你会双目失明。——索尔仁尼琴

要实现一个toast效果其实非常简单

image-20200922193402304

只需要这三行代码就能搞定

1
2
3
Toast shortToast = Toast.makeText(getApplicationContext(), "短Toast", Toast.LENGTH_SHORT);
shortToast.setGravity(Gravity.CENTER, 0, 0);
shortToast.show();

还有一种长toast

image-20200922193603011

同样非常简单

1
2
3
Toast longToast = Toast.makeText(getApplicationContext(), "长Toast", Toast.LENGTH_LONG);
longToast.setGravity(Gravity.CENTER, 0, 0);
longToast.show();