Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.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_Android Fragments_Android Activity_Android Softkeyboard - Fatal编程技术网

Java 如何防止键盘打开时底部视图向上推

Java 如何防止键盘打开时底部视图向上推,java,android,android-fragments,android-activity,android-softkeyboard,Java,Android,Android Fragments,Android Activity,Android Softkeyboard,屏幕上有两个edittext和屏幕底部的一个按钮,问题是当我单击edittext和键盘打开时,底部的按钮出现在键盘上方,我希望底部buton位于其原始位置,而不是随着键盘向上移动。按钮是底部对齐的 谢谢 附言: 我试过调整平移、调整大小等,但都不起作用 <activity android:screenOrientation="portrait" android:name=".activities.MainActivity" android:w

屏幕上有两个edittext和屏幕底部的一个按钮,问题是当我单击edittext和键盘打开时,底部的按钮出现在键盘上方,我希望底部buton位于其原始位置,而不是随着键盘向上移动。按钮是底部对齐的

谢谢

附言: 我试过调整平移、调整大小等,但都不起作用

<activity
        android:screenOrientation="portrait"
        android:name=".activities.MainActivity"
        android:windowSoftInputMode="stateUnchanged|adjustResize"
        android:theme="@style/AppTheme"
     />
XML:


在清单中的活动标记中更新以下内容:


android:WindowsOfInputMode=adjustNothing

这样设置XML文件,并根据需要进行更改

    <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff"
    android:orientation="vertical"
    android:paddingTop="20dp"
    android:elevation="5dp"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv_welcome"
        android:layout_marginRight="40dp"
        android:layout_marginStart="20dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:maxLines="2"
        style="App Wep"
        android:text="Welcome to the World \nof PACKR" />


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAllCaps="false"
        android:id="@+id/tv_continue"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@+id/tv_welcome"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="20dp"
        android:layout_marginStart="20dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:text="Sign in to continue" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_marginTop="20dp"
        android:layout_height="wrap_content"
        android:weightSum="1"
        android:layout_marginStart="20dp"
        android:layout_marginEnd="20dp"
        app:layout_constraintTop_toBottomOf="@+id/tv_continue"
        android:id="@+id/phone_layout"
        android:orientation="horizontal">

        <com.hbb20.CountryCodePicker
            android:layout_marginEnd="10dp"
            android:layout_width="0dp"
            android:layout_weight="0.4"
            android:textSize="12dp"
            android:id="@+id/countryCode"
            android:layout_height="match_parent" />

        <EditText
            android:layout_width="0dp"
            android:layout_weight="0.6"
            android:hint="Phone Number"
            android:inputType="number"
            android:id="@+id/et_phone"
            android:maxLength="11"
            android:padding="10dp"
            android:drawablePadding="10dp"
            android:layout_height="wrap_content" />
    </LinearLayout>


    <EditText
        android:layout_width="match_parent"
        android:layout_marginTop="10dp"
        android:hint="Password"
        android:singleLine="true"
        android:drawablePadding="10dp"
        android:layout_marginEnd="20dp"
        android:layout_marginStart="20dp"
        app:layout_constraintTop_toBottomOf="@+id/phone_layout"
        app:layout_constraintLeft_toLeftOf="parent"
        android:padding="10dp"
        android:inputType="textPassword"
        android:id="@+id/et_password"
        android:layout_height="wrap_content" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="wrap_content"
        android:id="@+id/forgot_layout"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="15dp"
        android:layout_height="wrap_content">


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/img_"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintRight_toRightOf="@+id/forgot_pass"
            app:layout_constraintLeft_toLeftOf="@+id/forgot_pass"
            android:layout_marginEnd="20dp"
            android:layout_marginStart="20dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:layout_marginEnd="20dp"
            android:layout_marginStart="20dp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/img_"
            android:layout_gravity="right"
            android:padding="5dp"
            android:id="@+id/forgot_pass"
            android:layout_marginTop="8dp" />
    </androidx.constraintlayout.widget.ConstraintLayout>


    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btn_signin"
        android:text="Login"
        app:layout_constraintTop_toBottomOf="@+id/et_password"
        android:layout_marginEnd="20dp"
        android:layout_marginStart="20dp"
        android:layout_marginTop="30dp"
        android:paddingLeft="5dp"
        />


    <ProgressBar
        android:id="@+id/pb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minHeight="50dp"
        android:minWidth="50dp"
        android:gravity="center"
        android:indeterminate="true"
        android:elevation="10dp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:indeterminateTintMode="src_atop"
        />



</androidx.constraintlayout.widget.ConstraintLayout>
并以这个例子来说明

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

删除Windows软输入模式。

显示XML布局删除Windows软输入模式标志并更改layout@Niceumang补充xml@Venky布局有什么变化?
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>