鸟语天空
自定义Toast
post by:追风剑情 2016-8-3 11:11

        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

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容