gpt4 book ai didi

java - NavigationBar 按钮在从服务绘制的布局上没有响应

转载 作者:行者123 更新时间:2023-11-30 08:52:51 26 4
gpt4 key购买 nike

我正在尝试实现一种 AlertWindow 类的东西,我正在使用 WindowsManager 的实例从服务View 可见且可访问。但是屏幕上 NavigationBar 上的后退/主页按钮似乎没有响应。我是 Android 新手。

这是我的代码 fragment :

        mLayout = new LinearLayout(this);
mLayout.setLayoutParams(new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT));

View view = LayoutInflater.from(this).inflate(R.layout.Mainactivity,
mLayout, true);
mTvErrorMsg = (TextView)view.findViewById(R.id.tv_error_msg);
mChkBoxAppState = (CheckBox)view.findViewById(R.id.chkbox_app_state);
mCancelBtn = (Button)view.findViewById(R.id.btn_action);

mEdtPin.addTextChangedListener(this);

try {
mWindowManager.addView(mLayout, wmlp);
} catch (RuntimeException e) {
SymLog.e(TAG, "Failed to add lock page.", e);

}

最佳答案

添加以下 LayoutParameters 解决了我的问题:

wmlp.flags = WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
wmlp.flags &= ~(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
wmlp.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
wmlp.format = -1;
wmlp.token = null;
wmlp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE;

关于java - NavigationBar 按钮在从服务绘制的布局上没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30044963/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com