//Toast.makeText(上下文,内容,显示时间);
Toast toast =Toast.makeText(this,"位置="+position+"内容="+text,Toast.LENGTH_SHORT);
//在屏幕中显示的位置,X轴的相对偏移,Y轴的相对偏移
toast.setGravity(Gravity.CENTER, 0, 0);
//运行展示
toast.show();

自定义Toast
LayoutInflater inflater=LayoutInflater.from(this);
View toast_view=inflater.inflate(R.layout.toast_layout,null);//获取自定义的layout
Toast toast=new Toast(this);//获取toast对象
toast.setView(toast_view);toast设置自定义的布局
Toast.show();//显示出来

  

相关文章:

  • 2021-08-20
  • 2022-01-31
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案