ScrollView内部的editText被InputKeyboard隐藏的问题

问题描述

嘿,

我有一个editText供用户输入其位置,该位置位于ScrollView中。当用户在其中单击时,我希望滚动视图滚动到editText字段下方,并且键盘也要出现。

现在我得到的是:

EditText is Hidden

设置滚动视图的代码部分是:

        final int[] location = {0,0};
    final int[] locationScroll = {0,0};
                keywordsedittext.getLocationInWindow(location);
            mainScroll.getLocationInWindow(locationScroll);
                float px = Utils.pixelsFromDP(keywordsedittext.getPaddingTop(),PropertyMainMenuActivity.this);
            location[1] = (int) (location[1] - locationScroll[1] - px);
                mainScroll.smoothScrollTo(0,location[1]);
            ((LockableScrollView) mainScroll).setScrollingEnabled(false);

            keywordsedittext.setFocusable(true);
            keywordsedittext.requestFocusFromTouch();
            InputMethodManager lManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            lManager.showSoftInput(keywordsedittext,0);

因此,基本上,滚动视图滚动到editText的Y高度坐标(删除了顶部填充)。 但是当执行代码时,editText的输入文本区域会被键盘输入隐藏。

我应该如何处理此问题?

解决方法

将此添加到ScrollView xml:

android:fillViewport="true"

将其添加到Manifest.xml

android:windowSoftInputMode="adjustResize"

你应该很好。

,

在清单中使用它

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

adjustPan移动页面内容而不调整其大小

有关更多信息 https://developer.android.com/guide/topics/manifest/activity-element