当软键可见时,android布局不会向上滚动

当软键可见时,android布局不会向上滚动,android,android-layout,android-relativelayout,manifest,Android,Android Layout,Android Relativelayout,Manifest,我已经将windowSoftInput设置为adjustResize,但键盘却隐藏了文本输入 这是我的布局xml <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/imageView1" android:paddi

我已经将windowSoftInput设置为adjustResize,但键盘却隐藏了文本输入

这是我的布局xml

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imageView1"
    android:paddingBottom="25dp"
    android:paddingLeft="35dp"
    android:paddingRight="35dp" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="50dp"
        android:layout_height="45dp"
        android:src="@drawable/user" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="45dp"
        android:layout_marginTop="0.4dp"
        android:layout_weight="0.41"
        android:background="@drawable/username_textbox"
        android:ems="10"
        android:minWidth="110dp"
        android:paddingLeft="8dp"
        android:singleLine="true" >
    </EditText>
</LinearLayout>
<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout1"
    android:paddingLeft="35dp"
    android:paddingRight="35dp" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="50dp"
        android:layout_height="45dp"
        android:layout_gravity="center_horizontal"
        android:src="@drawable/password_icon" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="45dp"
        android:layout_marginTop="0.4dp"
        android:background="@drawable/username_textbox"
        android:ems="10"
        android:minWidth="110dp"
        android:paddingLeft="8dp"
        android:singleLine="true" >
    </EditText>
</LinearLayout>

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout2"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:background="@drawable/background_signin"
    android:text="Login"
    android:textColor="#ffffff" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="175dp"
    android:layout_height="207dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="85dp"
    android:paddingBottom="20dp"
    android:src="@drawable/app_logo" />

 </RelativeLayout>


使用
而不是
调整大小

adjustResize
,顾名思义,调整窗口大小,为软键盘腾出空间,但在您的情况下,有足够的空间
adjustPan
滚动窗口,使聚焦视图保持可见。

使用
而不是
adjustResize

adjustResize
,顾名思义,调整窗口大小,为软键盘腾出空间,但在您的情况下,有足够的空间
adjustPan
滚动窗口,使聚焦视图保持可见。

使用
而不是
adjustResize

adjustResize
,顾名思义,调整窗口大小,为软键盘腾出空间,但在您的情况下,有足够的空间
adjustPan
滚动窗口,使聚焦视图保持可见。

使用
而不是
adjustResize


adjustResize
,顾名思义,调整窗口大小,为软键盘腾出空间,但在您的情况下,有足够的空间
adjustPan
滚动窗口,使聚焦视图保持可见。

我以前是这样使用的。它很好用

private int mSoftKeyboardHeight = 0;



protected void scrollDownOnKeyboardPopUp() {

    mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    int keyBoardHeight = 0;
                    if (keyBoardHeight <= 100) {
                        Rect r = new Rect();
                        mScrollView.getWindowVisibleDisplayFrame(r);

                        int screenHeight = mScrollView.getRootView().getHeight();
                        mSoftKeyboardHeight = screenHeight - (r.bottom - r.top);
                        int resourceId = getResources().getIdentifier("status_bar_height",
                                "dimen", "android");
                        if (resourceId > 0) {
                            mSoftKeyboardHeight -= getResources().getDimensionPixelSize(
                                    resourceId);
                        }
                        if (mSoftKeyboardHeight > 100) {
                            keyBoardHeight = mSoftKeyboardHeight;
                        }
                        mScrollView.scrollTo(mScrollView.getScrollY(), mSoftKeyboardHeight
                                + mBottomFunctionPanel.getHeight() + mChatEditPanel.getHeight()
                                + mScrollView.getScrollY());
                    }
                }
            });

}

我以前是这样的。它很好用

private int mSoftKeyboardHeight = 0;



protected void scrollDownOnKeyboardPopUp() {

    mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    int keyBoardHeight = 0;
                    if (keyBoardHeight <= 100) {
                        Rect r = new Rect();
                        mScrollView.getWindowVisibleDisplayFrame(r);

                        int screenHeight = mScrollView.getRootView().getHeight();
                        mSoftKeyboardHeight = screenHeight - (r.bottom - r.top);
                        int resourceId = getResources().getIdentifier("status_bar_height",
                                "dimen", "android");
                        if (resourceId > 0) {
                            mSoftKeyboardHeight -= getResources().getDimensionPixelSize(
                                    resourceId);
                        }
                        if (mSoftKeyboardHeight > 100) {
                            keyBoardHeight = mSoftKeyboardHeight;
                        }
                        mScrollView.scrollTo(mScrollView.getScrollY(), mSoftKeyboardHeight
                                + mBottomFunctionPanel.getHeight() + mChatEditPanel.getHeight()
                                + mScrollView.getScrollY());
                    }
                }
            });

}

我以前是这样的。它很好用

private int mSoftKeyboardHeight = 0;



protected void scrollDownOnKeyboardPopUp() {

    mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    int keyBoardHeight = 0;
                    if (keyBoardHeight <= 100) {
                        Rect r = new Rect();
                        mScrollView.getWindowVisibleDisplayFrame(r);

                        int screenHeight = mScrollView.getRootView().getHeight();
                        mSoftKeyboardHeight = screenHeight - (r.bottom - r.top);
                        int resourceId = getResources().getIdentifier("status_bar_height",
                                "dimen", "android");
                        if (resourceId > 0) {
                            mSoftKeyboardHeight -= getResources().getDimensionPixelSize(
                                    resourceId);
                        }
                        if (mSoftKeyboardHeight > 100) {
                            keyBoardHeight = mSoftKeyboardHeight;
                        }
                        mScrollView.scrollTo(mScrollView.getScrollY(), mSoftKeyboardHeight
                                + mBottomFunctionPanel.getHeight() + mChatEditPanel.getHeight()
                                + mScrollView.getScrollY());
                    }
                }
            });

}

我以前是这样的。它很好用

private int mSoftKeyboardHeight = 0;



protected void scrollDownOnKeyboardPopUp() {

    mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    int keyBoardHeight = 0;
                    if (keyBoardHeight <= 100) {
                        Rect r = new Rect();
                        mScrollView.getWindowVisibleDisplayFrame(r);

                        int screenHeight = mScrollView.getRootView().getHeight();
                        mSoftKeyboardHeight = screenHeight - (r.bottom - r.top);
                        int resourceId = getResources().getIdentifier("status_bar_height",
                                "dimen", "android");
                        if (resourceId > 0) {
                            mSoftKeyboardHeight -= getResources().getDimensionPixelSize(
                                    resourceId);
                        }
                        if (mSoftKeyboardHeight > 100) {
                            keyBoardHeight = mSoftKeyboardHeight;
                        }
                        mScrollView.scrollTo(mScrollView.getScrollY(), mSoftKeyboardHeight
                                + mBottomFunctionPanel.getHeight() + mChatEditPanel.getHeight()
                                + mScrollView.getScrollY());
                    }
                }
            });

}