简体   繁体   English

应用沉浸模式时出现软键盘时,EditText和Button上的片段上的键盘重叠

[英]Overlapping Keyboard on EditText and Button in fragments when soft keyboard appears when apply immersive mode

I want to use the soft keyboard, but it hides my EditText or buttons, I need it to scroll so the keyboard is not hiding it. 我想使用软键盘,但它会隐藏我的EditText或按钮,我需要滚动它以便键盘不会隐藏它。 It's working very well with Activity, but not working with Fragment. 它与Activity配合得很好,但与Fragment搭配不了。

I'm trying with this code: 我正在尝试使用以下代码:

 @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }

And also try this code: 并尝试以下代码:

@Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }

Anybody got any suggestions for Fragment? 有人对Fragment有任何建议吗?

Try this in the manifest of the particular activity 在特定活动的清单中尝试此操作

<activity
    android:name=".YourActivity"
    android:label="@string/app_name"
    android:windowSoftInputMode="stateAlwaysHidden|adjustResize/>

or in the oncreate of the activity 或在活动创建时

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM