android.view.WindowManager.LayoutParams#FLAG_NOT_TOUCH_MODAL源码实例Demo

下面列出了android.view.WindowManager.LayoutParams#FLAG_NOT_TOUCH_MODAL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: QSVideoPlayer   文件: WindowManage.java
public WindowManager.LayoutParams creatParams(int type, FloatParams floatParams) {
    //系统浮窗不能超出边界,更新xy
    int ww = (w - floatParams.w) / 2;
    int hh = (h - floatParams.h) / 2;
    if (Math.abs(floatParams.x) > ww)
        floatParams.x = floatParams.x > 0 ? ww : -ww;
    if (Math.abs(floatParams.y) > hh)
        floatParams.y = floatParams.y > 0 ? hh : -hh;

    LayoutParams smallWindowParams = new LayoutParams();
    smallWindowParams.type = type;
    smallWindowParams.format = PixelFormat.RGBA_8888;
    smallWindowParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
            | LayoutParams.FLAG_NOT_FOCUSABLE;
    //smallWindowParams.gravity = Gravity.LEFT | Gravity.TOP;
    smallWindowParams.width = floatParams.w;
    smallWindowParams.height = floatParams.h;
    smallWindowParams.x = floatParams.x;
    smallWindowParams.y = floatParams.y;
    return smallWindowParams;
}
 
源代码2 项目: BalloonPerformer   文件: HandView.java
/**
 * attach handview to {@link WindowManager}
 *
 * @param y
 */
public void attachToWindow(int x, int y) {
    if (this.getParent() != null) {
        return;
    }
    mLp = new WindowManager.LayoutParams();
    mLp.type = LayoutParams.TYPE_SYSTEM_ALERT;
    mLp.format = PixelFormat.RGBA_8888;
    mLp.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
            | LayoutParams.FLAG_NOT_FOCUSABLE;
    mLp.gravity = Gravity.LEFT | Gravity.TOP;
    mLp.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mLp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mLp.x = x;
    mOriY = y;
    mLp.y = mOriY;
    mWindowManager.addView(this, mLp);
}
 
源代码3 项目: Noyze   文件: StatusBarVolumePanel.java
@Override public WindowManager.LayoutParams getWindowLayoutParams() {
	int flags = (LayoutParams.FLAG_NOT_FOCUSABLE		|
                    LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH  |
                    LayoutParams.FLAG_NOT_TOUCH_MODAL      |
                    LayoutParams.FLAG_LAYOUT_INSET_DECOR   |
			     LayoutParams.FLAG_LAYOUT_IN_SCREEN		|
			     LayoutParams.FLAG_SHOW_WHEN_LOCKED	    );
	LayoutParams WPARAMS = new WindowManager.LayoutParams(
		LayoutParams.MATCH_PARENT, mStatusBarHeight, 0, 0,
		LayoutParams.TYPE_SYSTEM_ERROR, flags, PixelFormat.TRANSLUCENT);
	WPARAMS.windowAnimations = android.R.style.Animation_Dialog;
	WPARAMS.packageName = getContext().getPackageName();
	WPARAMS.setTitle(TAG);
       WPARAMS.rotationAnimation = LayoutParams.ROTATION_ANIMATION_JUMPCUT;
	WPARAMS.gravity = (Gravity.FILL_HORIZONTAL | Gravity.TOP);
	WPARAMS.screenBrightness = WPARAMS.buttonBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
	return WPARAMS;
}
 
源代码4 项目: android-art-res   文件: TestActivity.java
public void onButtonClick(View v) {
    if (v == mCreateWindowButton) {
        mFloatingButton = new Button(this);
        mFloatingButton.setText("click me");
        mLayoutParams = new WindowManager.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0,
                PixelFormat.TRANSPARENT);
        mLayoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
                | LayoutParams.FLAG_NOT_FOCUSABLE
                | LayoutParams.FLAG_SHOW_WHEN_LOCKED;
        mLayoutParams.type = LayoutParams.TYPE_SYSTEM_ERROR;
        mLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
        mLayoutParams.x = 100;
        mLayoutParams.y = 300;
        mFloatingButton.setOnTouchListener(this);
        mWindowManager.addView(mFloatingButton, mLayoutParams);
    }
}
 
源代码5 项目: Noyze   文件: StatusBarVolumePanel.java
@Override public WindowManager.LayoutParams getWindowLayoutParams() {
	int flags = (LayoutParams.FLAG_NOT_FOCUSABLE		|
                    LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH  |
                    LayoutParams.FLAG_NOT_TOUCH_MODAL      |
                    LayoutParams.FLAG_LAYOUT_INSET_DECOR   |
			     LayoutParams.FLAG_LAYOUT_IN_SCREEN		|
			     LayoutParams.FLAG_SHOW_WHEN_LOCKED	    );
	LayoutParams WPARAMS = new WindowManager.LayoutParams(
		LayoutParams.MATCH_PARENT, mStatusBarHeight, 0, 0,
		LayoutParams.TYPE_SYSTEM_ERROR, flags, PixelFormat.TRANSLUCENT);
	WPARAMS.windowAnimations = android.R.style.Animation_Dialog;
	WPARAMS.packageName = getContext().getPackageName();
	WPARAMS.setTitle(TAG);
       WPARAMS.rotationAnimation = LayoutParams.ROTATION_ANIMATION_JUMPCUT;
	WPARAMS.gravity = (Gravity.FILL_HORIZONTAL | Gravity.TOP);
	WPARAMS.screenBrightness = WPARAMS.buttonBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
	return WPARAMS;
}
 
源代码6 项目: styT   文件: Takt.java
private Program prepare(Application application) {
    metronome = new Metronome();
    params = new LayoutParams();
    params.width = LayoutParams.WRAP_CONTENT;
    params.height = LayoutParams.WRAP_CONTENT;
    // if (isOverlayApiDeprecated()) {
    // params.type = LayoutParams.TYPE_APPLICATION_OVERLAY;
    // } else {
    params.type = LayoutParams.TYPE_TOAST;
    //}
    params.flags = LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_NOT_FOCUSABLE
            | LayoutParams.FLAG_NOT_TOUCH_MODAL;
    params.format = PixelFormat.TRANSLUCENT;
    params.gravity = Seat.BOTTOM_RIGHT.getGravity();
    params.x = 10;

    app = application;
    wm = WindowManager.class.cast(application.getSystemService(Context.WINDOW_SERVICE));
    LayoutInflater inflater = LayoutInflater.from(app);
    stageView = inflater.inflate(R.layout.stage, new RelativeLayout(app));
    fpsText = stageView.findViewById(R.id.takt_fps);

    listener(new Audience() {
        @Override
        public void heartbeat(double fps) {
            if (fpsText != null) {
                fpsText.setText(decimal.format(fps));
            }
        }
    });

    return this;
}
 
源代码7 项目: stynico   文件: Takt.java
private Program prepare(Application application) {
    metronome = new Metronome();
    params = new LayoutParams();
    params.width = LayoutParams.WRAP_CONTENT;
    params.height = LayoutParams.WRAP_CONTENT;
    // if (isOverlayApiDeprecated()) {
    // params.type = LayoutParams.TYPE_APPLICATION_OVERLAY;
    // } else {
    params.type = LayoutParams.TYPE_TOAST;
    //}
    params.flags = LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_NOT_FOCUSABLE
            | LayoutParams.FLAG_NOT_TOUCH_MODAL;
    params.format = PixelFormat.TRANSLUCENT;
    params.gravity = Seat.BOTTOM_RIGHT.getGravity();
    params.x = 10;

    app = application;
    wm = WindowManager.class.cast(application.getSystemService(Context.WINDOW_SERVICE));
    LayoutInflater inflater = LayoutInflater.from(app);
    stageView = inflater.inflate(R.layout.stage, new RelativeLayout(app));
    fpsText = (TextView) stageView.findViewById(R.id.takt_fps);

    listener(new Audience() {
        @Override
        public void heartbeat(double fps) {
            if (fpsText != null) {
                fpsText.setText(decimal.format(fps));
            }
        }
    });

    return this;
}
 
源代码8 项目: Takt   文件: Takt.java
private Program prepare(Application application) {
  metronome = new Metronome();
  params = new LayoutParams();
  params.width = LayoutParams.WRAP_CONTENT;
  params.height = LayoutParams.WRAP_CONTENT;
  application.registerActivityLifecycleCallbacks(new LifecycleListener(this));

  if (isOverlayApiDeprecated()) {
    params.type = LayoutParams.TYPE_APPLICATION_OVERLAY;
  } else {
    params.type = LayoutParams.TYPE_TOAST;
  }
  params.flags = LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_NOT_FOCUSABLE
      | LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_TOUCHABLE;
  params.format = PixelFormat.TRANSLUCENT;
  params.gravity = Seat.BOTTOM_RIGHT.getGravity();
  params.x = 10;

  app = application;
  wm = WindowManager.class.cast(application.getSystemService(Context.WINDOW_SERVICE));
  LayoutInflater inflater = LayoutInflater.from(app);
  stageView = inflater.inflate(R.layout.stage, new RelativeLayout(app));
  fpsText = stageView.findViewById(R.id.takt_fps);

  listener(new Audience() {
    @Override public void heartbeat(double fps) {
      if (fpsText != null) {
        fpsText.setText(decimal.format(fps));
      }
    }
  });

  return this;
}
 
源代码9 项目: RePlugin-GameSdk   文件: FunFloatingTool.java
/**
 * 要显示在窗口最前面的方法
 * 
 * @param context
 *            调用对象Context getApplicationContext()
 * @param window
 *            调用对象 Window getWindow()
 * @param floatingViewObj
 *            要显示的浮动对象 View
 */
public static void show(Context context, View floatingViewObj) {

	mFloatingViewObj = floatingViewObj;

	view_obj = mFloatingViewObj;
	Rect frame = new Rect();
	// 这一句是关键,让其在top 层显示
	// getWindow()
	// window.getDecorView().getWindowVisibleDisplayFrame(frame);
	TOOL_BAR_HIGH = frame.top;

	wm = (WindowManager) context// getApplicationContext()
			.getSystemService(Context.WINDOW_SERVICE);

	params.type = WindowManager.LayoutParams.TYPE_APPLICATION;// 2;
	// params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
	// | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
	// params.type = 2003;//WindowManager.LayoutParams.TYPE_PHONE;
	params.format = -2;
	params.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
			| LayoutParams.FLAG_NOT_FOCUSABLE;

	// 设置悬浮窗口长宽数据
	params.width = WindowManager.LayoutParams.WRAP_CONTENT;
	params.height = HWUtils.dip2px(context, 60);
	// 设定透明度
	params.alpha = 80;
	// 设定内部文字对齐方式
	params.gravity = Gravity.LEFT | Gravity.TOP;

	screenWidth = wm.getDefaultDisplay().getWidth(); // 屏幕宽(像素,如:480px)
	screenHeight = wm.getDefaultDisplay().getHeight(); // 屏幕高(像素,如:800px)
	// 以屏幕左上角为原点,设置x、y初始值ֵ
	// params.x = (int) (screenWidth - params.width);
	String postions = HWPreferences.getData(context, "HW_postions");
	String mY = HWPreferences.getData(context, "HW_currentY");
	if (null != postions && null != mY && 0 < mY.length()) {
		if (Boolean.valueOf(postions)) {
			params.x = params.width;
		} else {
			params.x = (int) (screenWidth - params.width);
		}
		isLeftPosition = Boolean.valueOf(postions);
		params.y = Integer.valueOf(mY) + 60;

	} else {
		params.x = params.width;
		params.y = ((screenHeight - params.height) / 2) + 60;

	}
	// params.y = (int) y;
	// tv = new MyTextView(TopFrame.this);

	wm.addView(floatingViewObj, params);
	wm.updateViewLayout(mFloatingViewObj, params);
	isShow = true;
	mIsShow = true; // 定时器检测浮标是否已经显示出来的标志

}