Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 显示软键盘时,向上滑动视图_Java_Android - Fatal编程技术网

Java 显示软键盘时,向上滑动视图

Java 显示软键盘时,向上滑动视图,java,android,Java,Android,我想在软键盘出现时向上滑动窗体视图。 我发现这并不像我想象的那么简单,我尝试将活动的windowsofInputMode更改为adjustPan,但它什么也不做,然后我尝试将其更改为adjustResize,它只是调整了按钮的高度 我期望的结果示例: 当用户单击其中一个编辑文本视图时,我希望这些视图向上滑动: 编辑:这是我的布局文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" x

我想在软键盘出现时向上滑动窗体视图。 我发现这并不像我想象的那么简单,我尝试将活动的
windowsofInputMode
更改为
adjustPan
,但它什么也不做,然后我尝试将其更改为
adjustResize
,它只是调整了按钮的高度

我期望的结果示例:

当用户单击其中一个编辑文本视图时,我希望这些视图向上滑动:

编辑:这是我的布局文件:

<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"
tools:context="com.example.invity.Login"
android:background="#5dc8fc"
android:id="@+id/rlLogin">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:background="#5dc8fc"
style="@style/AppBaseThemeNoTitle" >

    <ImageView
        android:id="@+id/imgBG1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:scaleType="matrix"
        android:src="@drawable/BG1" />

    <ImageView
        android:id="@+id/imgBG2"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_alignParentBottom="true"
        android:scaleType="centerCrop"
        android:src="@drawable/BG2" />

</RelativeLayout>

<ImageView
    android:id="@+id/imgLogo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="190dp"
    android:src="@drawable/logo_white"
    android:fitsSystemWindows="true" />

<EditText
    android:id="@+id/txtEmail"
    android:layout_width="350dp"
    android:layout_height="50dp"
    android:layout_centerHorizontal="true"
    android:hint="@string/app_login_Email_Hint"
    android:layout_below="@+id/imgLogo"
    android:layout_marginTop="16dp"
    android:layout_marginBottom="5dp"
    android:paddingLeft="3dp"
    android:ems="15"
    android:inputType="textEmailAddress"
    android:background="@drawable/edittext_style"
    android:gravity="center"
    android:singleLine="true"
    android:textDirection="ltr"
    android:textColor="#58c9f3"
    android:fitsSystemWindows="true">

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/txtPassword"
    android:layout_width="350dp"
    android:layout_height="50dp"
    android:layout_centerHorizontal="true"
    android:hint="@string/app_login_Password_Hint"
    android:layout_below="@+id/txtEmail"
    android:layout_marginBottom="5dp"
    android:paddingLeft="3dp"
    android:ems="15"
    android:inputType="textPassword"
    android:background="@drawable/edittext_style"
    android:gravity="center"
    android:singleLine="true"
    android:textDirection="ltr"
    android:textColor="#58c9f3"
    android:fitsSystemWindows="true"/>

<Button
    android:id="@+id/btnConnect"
    android:layout_width="350dp"
    android:layout_height="55dp"
    android:layout_centerHorizontal="true"
    android:layout_alignLeft="@+id/txtPassword"
    android:layout_alignRight="@+id/txtPassword"
    android:layout_below="@+id/txtPassword"
    android:text="@string/app_login_btn"
    android:onClick="btnLoginClick"
    android:background="@drawable/button_style"
    android:textColor="#FFFFFF"
    android:textSize="20sp"
    android:fitsSystemWindows="true"/>

</RelativeLayout>

我有两个图像视图,它们将背景放在一起。

您需要请求焦点()

如果你不能要求焦点,你可以使用

(!EditText.hasFocus()){
//do nothing}
else{EditText.requestFocus();}

通过某种更新方法

可以显示布局文件。adjustResize应该是你正在寻找的它只是调整我的按钮大小。可能是因为视图后面的两个图像视图?请看这里:谢谢,但这与我的问题无关。