/**
* 修改toast显示到中间位置
*
* @param message 需要展示的信息
*/
public void showCenterToastCenter(String message) {
LayoutInflater inflater = getLayoutInflater();
LinearLayout linear = (LinearLayout) inflater.inflate(R.layout.layout_toast, null);
TextView tvToast = linear.findViewById(R.id.tv_toast);
tvToast.setText(message);
Toast toast = new Toast(getApplicationContext());
toast.setView(linear);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
Android 自定义Toast
最新推荐文章于 2024-08-19 15:33:00 发布