自定义Toast

作者:追风剑情 发布于:2016-8-3 11:11 分类:Android

        public void showToast()
	{
		String msg = "To the bride and groom!";
		int duration = Toast.LENGTH_LONG;
		Toast toast = Toast.makeText(this, msg, duration);
		int offsetX = 0;
		int offsetY = 0;
		//设置位置
		toast.setGravity(Gravity.BOTTOM, offsetX, offsetY);
		//设置自定义视图
		LayoutInflater inflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	        View view = inflater.inflate(R.layout.toast_view, null);
		toast.setView(view);
		//显示
		toast.show();
	}

运行测试

111111.png

标签: Android

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号