网上一张解释DecorView的图
蒙板新手引导示例代码:
public class GuideViewUtil {
private Activity mActivity;
public GuideViewUtil(Activity activity, int layoutBottom) {
this.mActivity = activity;
}
public void showGuide() {
if (mActivity == null) {
return;
}
//获取Activity的decorView
final FrameLayout flRoot = (FrameLayout) mActivity.getWindow().getDecorView();
final RelativeLayout guideView = (RelativeLayout) LayoutInflater.from(mActivity).inflate(R.layout.layout_guide_find_student, flRoot, false);
guideView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//点击蒙板后去掉该View
flRoot.removeView(guideView);
}
});
flRoot.addView(guideView);
}