如何向上移动layoutFragment当Android是所示的软键盘?

问题描述 投票:4回答:3

我有这个页面:

但是,当打开softWareKeyBoard我看不到其他EditText。我能做什么?

注意:我使用下面的代码,但没有奏效。而我classextends Fragment

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
android android-layout android-fragments fragment android-softkeyboard
3个回答
1
投票

有两种方法可以做到这一点无论您可以在清单活动使用

它会为工作,调整锅将向上流动的表面,并打开软键盘

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

<activity android:name="XXXActivity" android:windowSoftInputMode="adjustPan">
</activity>

-1
投票

工作守则

对于片段:

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

对于活动:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

-2
投票

我用这样的以编程方式显示软键盘,这是为我工作,以防止屏幕的自动调整,同时推出的键盘。

EditText et =  (EditText))findViewById(R.id.edit_text);  
  Timer timer = new Timer();
            TimerTask task = new TimerTask() {

                @Override
                public void run() {
                    InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputMethodManager.toggleSoftInputFromWindow(et.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);

                }
            };
            timer.schedule(task, 200);

在清单文件的使用:

<activity android:name="XXXActivity" android:windowSoftInputMode="adjustPan">
</activity>
© www.soinside.com 2019 - 2024. All rights reserved.