android设置自定义Toast View

设置一个简单的自定义Toast View,里面只用了一个TextView

	public void showToast(int resid){
		String text = mActivity.getResources().getString(resid);
		showToast(text);
	}

	public void showToast(String text){
		Toast toast = new Toast(mActivity);
		TextView info = new TextView(mActivity);
		info.setBackgroundResource(R.drawable.tips_bg);
		info.setTextSize(30);
		info.setTypeface(MusicQuery.TF_SQUARE);
		info.setTextColor(0xffffffff);
		ViewGroup.LayoutParams lps = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
		info.setLayoutParams(lps);
		toast.setDuration(Toast.LENGTH_LONG);
		info.setText(text);
		toast.setView(info);
		toast.show();
	}

你可能感兴趣的:(技术文档)