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

2017-06-07  本文已影响0人  Jayden_

网上一张解释DecorView的图

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);
    }
上一篇 下一篇

猜你喜欢

热点阅读