代码之家  ›  专栏  ›  技术社区  ›  Dr4ke the b4dass

即使清单中设置了“调整大小”或“调整范围”,软键盘也会隐藏视图

  •  0
  • Dr4ke the b4dass  · 技术社区  · 6 年前

    <activity
            android:name=".view.main.MainActivity"
            android:configChanges="orientation"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
    
    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout 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"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_create_account">
    
    <View
        android:id="@+id/vail"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black_two" />
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_gravity="center"
            android:background="@color/black"
            android:gravity="center_horizontal"
            android:paddingTop="@dimen/status_bar_height">
    
            <TextView
                style="@style/ProximaNova18PtWhite"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:lineSpacingExtra="4sp"
                android:text="@string/create_account"
                android:textAllCaps="true"
                android:textColor="@color/white"
                android:textSize="16sp" />
    
    
        </androidx.appcompat.widget.Toolbar>
    
        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">
    
            <LinearLayout
                android:id="@+id/inner_root"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
    
                <View
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1" />
    
                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/username_layout"
                    style="@style/LoginTextInputLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/content_margin"
                    android:layout_marginEnd="@dimen/content_margin"
                    android:hint="@string/username"
                    app:hintAnimationEnabled="true"
                    app:hintTextAppearance="@style/ProximaNova14Pt"
                    app:hintTextColor="@color/white">
    
                    <androidx.appcompat.widget.AppCompatEditText
                        android:id="@+id/username_edit"
                        style="@style/LoginEdittextStyle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:importantForAutofill="noExcludeDescendants"
                        android:inputType="textEmailAddress"
                        android:textColorHint="@color/white"
                        tools:text="dewe" />
    
                </com.google.android.material.textfield.TextInputLayout>
    
                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/email_layout"
                    style="@style/LoginTextInputLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/content_margin"
                    android:layout_marginTop="20dp"
                    android:layout_marginEnd="@dimen/content_margin"
                    android:hint="@string/email"
                    app:hintAnimationEnabled="true"
                    app:hintTextAppearance="@style/ProximaNova14Pt"
                    app:hintTextColor="@color/white">
    
                    <androidx.appcompat.widget.AppCompatEditText
                        android:id="@+id/email_edit"
                        style="@style/LoginEdittextStyle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:importantForAutofill="noExcludeDescendants"
                        android:inputType="textEmailAddress"
                        android:textColorHint="@color/white"
                        tools:text="dewe" />
    
                </com.google.android.material.textfield.TextInputLayout>
    
                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/password_layout"
                    style="@style/LoginTextInputLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/content_margin"
                    android:layout_marginTop="20dp"
                    android:layout_marginEnd="@dimen/content_margin"
                    android:hint="@string/password"
                    app:hintAnimationEnabled="true"
                    app:hintTextAppearance="@style/ProximaNova14Pt"
                    app:hintTextColor="@color/white">
    
                    <androidx.appcompat.widget.AppCompatEditText
                        android:id="@+id/password_edit"
                        style="@style/LoginEdittextStyle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:importantForAutofill="noExcludeDescendants"
                        android:inputType="textPassword"
                        android:textColorHint="@color/white"
                        tools:text="dewe" />
    
                </com.google.android.material.textfield.TextInputLayout>
    
                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/confirm_password_layout"
                    style="@style/LoginTextInputLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/content_margin"
                    android:layout_marginTop="20dp"
                    android:layout_marginEnd="@dimen/content_margin"
                    android:hint="@string/confirm_password"
                    app:hintAnimationEnabled="true"
                    app:hintTextAppearance="@style/ProximaNova14Pt"
                    app:hintTextColor="@color/white">
    
                    <androidx.appcompat.widget.AppCompatEditText
                        android:id="@+id/confirm_password_edit"
                        style="@style/LoginEdittextStyle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:importantForAutofill="noExcludeDescendants"
                        android:inputType="textPassword"
                        android:textColorHint="@color/white"
                        tools:text="dewe" />
    
                </com.google.android.material.textfield.TextInputLayout>
    
                <androidx.appcompat.widget.AppCompatCheckBox
                    android:id="@+id/checkbox"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginStart="@dimen/content_margin"
                    android:layout_marginTop="40dp"
                    android:layout_marginEnd="@dimen/content_margin"
                    android:checked="true"
                    android:hint="@string/i_agree_to_all_the_terms_and_conditions"
                    android:padding="0dp"
                    android:textAppearance="@style/ProximaNova14Pt"
                    android:textColorHint="@color/white"
                    app:buttonTint="@color/white" />
    
    
                <androidx.appcompat.widget.AppCompatButton
                    android:id="@+id/create_account_button"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_marginStart="@dimen/content_margin"
                    android:layout_marginTop="40dp"
                    android:layout_marginEnd="@dimen/content_margin"
                    android:background="@drawable/bg_login_button"
                    android:fontFamily="@font/proxima_nova_regular"
                    android:lineSpacingExtra="4sp"
                    android:text="@string/create_account_button"
                    android:textAllCaps="true"
                    android:textColor="@color/white"
                    android:textSize="18sp" />
    
                <View
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1" />
    
                <FrameLayout
                    android:id="@+id/terms"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:background="@drawable/text_view_button_selector"
                    android:layout_marginBottom="@dimen/default_margin"
                    android:padding="@dimen/default_margin_half">
    
                    <TextView
                        style="@style/ProximaNova14Pt"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/view_terms_and_conditions" />
    
                </FrameLayout>
    
                <View
                    android:id="@+id/stub"
                    android:layout_width="match_parent"
                    android:layout_height="56dp"
                    android:visibility="gone" />
    
            </LinearLayout>
    
        </androidx.core.widget.NestedScrollView>
    
    </LinearLayout>
    

    0 回复  |  直到 6 年前
        1
  •  0
  •   Ronak Patel    6 年前

    将其添加到清单文件中,并在父布局中应用滚动视图。。

    android:windowSoftInputMode="adjustResize"
    
    推荐文章