網(wǎng)上一張解釋DecorView的圖
蒙板新手引導(dǎo)示例代碼:
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) {
//點(diǎn)擊蒙板后去掉該View
flRoot.removeView(guideView);
}
});
flRoot.addView(guideView);
}