1

我正面临一个奇怪的问题。我在一个活动中有两个片段。一个是登录 Fragment 。我在这个片段中有两个编辑文本。此文件中的某些设备被软键盘隐藏,我在清单中指定了adjustPan,这工作正常

当用户单击 LoginFragment 上的按钮时,我正在打开另一个名为 forgetpassword 的片段。这是一个 webview,url 正在从远程服务器加载。但是 html 中的文本字段被软键盘隐藏。所以我尝试使用adjustResize,它工作正常。但是我在 loginfragment 中的 editText 小部件被键盘隐藏。

我怎样才能在我的活动中实现这两个标志。请帮我解决一下这个。

4

3 回答 3

1

You can solve your problem by setting adjustPan and adjustResize programmatically.

Use the following code to set ajustPan when the current Fragment is your LoginFragment:

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

And use the following code to set ajustResize when the current Fragment is your webview Fragment:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
于 2015-01-28T07:25:02.347 回答
0

adjustResize并且adjustPan不能相互结合。它们是防止软输入覆盖输入字段的不同默认操作。如评论中所示WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN

    /** Adjustment option for {@link #softInputMode}: set to allow the
     * window to be resized when an input
     * method is shown, so that its contents are not covered by the input
     * method.  This can <em>not</em> be combined with
     * {@link #SOFT_INPUT_ADJUST_PAN}; if
     * neither of these are set, then the system will try to pick one or
     * the other depending on the contents of the window. If the window's
     * layout parameter flags include {@link #FLAG_FULLSCREEN}, this
     * value for {@link #softInputMode} will be ignored; the window will
     * not resize, but will stay fullscreen.
     */
    public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
于 2016-03-31T08:51:20.390 回答
-1

adjustPan您可以通过设置和adjustResize编程来解决您的问题。此外,在listview添加android:transcriptMode="alwaysScroll"

于 2016-03-08T10:00:52.103 回答