Android Toast带图标水平布局的简单实现

//创建Toast对象
        	Toast mToast = Toast.makeText(ShareYourLifeActivity.this, "内存卡不可用,请检查...", Toast.LENGTH_LONG);
        	
        	//创建LinearLayout布局
        	LinearLayout toastView = (LinearLayout) mToast.getView();
        	
        	//设置LinearLayout的布局取向
        	toastView.setOrientation(LinearLayout.HORIZONTAL);
        	
        	//创建ImageView
        	ImageView imageCodeProject = new ImageView(getApplicationContext());
        	imageCodeProject.setImageResource(R.drawable.icon);
        	
        	//给toastView添加View布局
        	toastView.addView(imageCodeProject, 0);

        	//显示Toast
        	mToast.show();

图示: Android Toast带图标水平布局的简单实现

你可能感兴趣的:(android,toast,图标,水平取向)