利用getDecorView()编写蒙板新手引导

网上一张解释DecorView的图

利用getDecorView()编写蒙板新手引导_第1张图片
20141205184654359.jpg

蒙板新手引导示例代码:

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);
    }

你可能感兴趣的:(利用getDecorView()编写蒙板新手引导)