Scrollview在显示android软键盘时向上推

我在scrollView中有一个editext.当editext获得焦点并显示键盘时,ScrollView会自动向上推.

我试过了

机器人:windowSoftInputMode = “adjustResize”
机器人:windowSoftInputMode = “adjustPan”

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sign_in_or_sign_up_bg" >

<RelativeLayout
    android:id="@+id/headerlayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="@drawable/headerBox_title" >

    <ImageButton
        android:id="@+id/backImgBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:background="@null"
        android:src="@drawable/backarrow" />
</RelativeLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/headerlayout"
    android:fillViewport="true" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="vertical" >

        <ImageButton
            android:id="@+id/profilePicImgBtn"
            android:layout_width="@dimen/sign_up_profile_pic"
            android:layout_height="@dimen/sign_up_profile_pic"
            android:layout_gravity="center_horizontal"
            android:background="@null"
            android:scaleType="centerCrop"
            android:src="@drawable/attach_image" />

        <EditText
            android:id="@+id/userNameEdt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/sign_in_small_margin"
            android:background="@drawable/text_Box"
            android:hint="Username"
            android:imeOptions="actionNext"
            android:padding="@dimen/edt_padding"
            android:singleLine="true"
            android:textSize="@dimen/edt_hint" />

        <EditText
            android:id="@+id/emailEdt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/sign_in_small_margin"
            android:background="@drawable/text_Box"
            android:hint="Email"
            android:imeOptions="actionNext"
            android:inputType="textEmailAddress"
            android:padding="@dimen/edt_padding"
            android:singleLine="true"
            android:textSize="@dimen/edt_hint" />

        <EditText
            android:id="@+id/passwordEdt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/sign_in_small_margin"
            android:background="@drawable/text_Box"
            android:hint="Password"
            android:imeOptions="actionNext"
            android:inputType="textPassword"
            android:padding="@dimen/edt_padding"
            android:singleLine="true"
            android:textSize="@dimen/edt_hint" />

        <EditText
            android:id="@+id/retypePasswordEdt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/sign_in_small_margin"
            android:background="@drawable/text_Box"
            android:hint="Retype Password"
            android:imeOptions="actionDone"
            android:inputType="textPassword"
            android:padding="@dimen/edt_padding"
            android:singleLine="true"
            android:textSize="@dimen/edt_hint" />

        <ImageButton
            android:id="@+id/signUpImgBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/sign_in_large_margin"
            android:background="@null"
            android:src="@drawable/sing_up_main_btn" />
    </LinearLayout>
</ScrollView>

解决方法

在你的oncreate添加
getwindow().setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_ADJUST_PAN);

更新

尝试将此添加到您的滚动视图

android:isScrollContainer="false"

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...