我的智能手机有软键,我想永久隐藏在我的 APP 中。我使用下面的那个功能来隐藏软键。
public void setFullscreen(boolean fullscreen) {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
if (fullscreen) {
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
attrs.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
}
else {
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
}
getWindow().setAttributes(attrs);
View v = this.getWindow().getDecorView();
v.setSystemUiVisibility(View.GONE);
}
我在 onCreate 的所有活动中调用该函数,然后像这样受保护的 void onCreate(Bundle savedInstanceState)..
@Override
protected void onCreate(Bundle savedInstanceState)
{
setFullscreen(true);
super.onCreate(savedInstanceState);
setContentView(R.layout.myLayout);
}
问题:我正在更改活动,并且软键再次出现并隐藏。我如何防止它们出现?
我还在清单中为所有活动使用“stateHidden”
<activity
android:name=".myActivity"
android:windowSoftInputMode="stateHidden" />
希望你能帮助我......非常感谢!:)