看了秋大的一些源码,记录一下。
private void showTestToast() {
if (toastView == null) {
toastView = View.inflate(this, R.layout.pop_view, null);
simpleTxt = (TextView) toastView.findViewById(R.id.pop_view_text);
toastView.setOnClickListener(this);
}
simpleTxt.setText("this is a simple text");
int w = WindowManager.LayoutParams.MATCH_PARENT;
int h = WindowManager.LayoutParams.WRAP_CONTENT;
int flag = 0;
int type = WindowManager.LayoutParams.TYPE_TOAST;
WindowManager.LayoutParams params = new WindowManager.LayoutParams(w, h, type, flag, PixelFormat.TRANSLUCENT);
params.gravity = Gravity.CENTER;
mWindowManager.addView(toastView, params);}
同时看了windowManager的高端知识,以后过来回顾。