gpt4 book ai didi

android - SoftKeyboard 与 EditText 重叠 - ConstraintLayout

转载 作者:行者123 更新时间:2023-11-29 02:22:17 33 4
gpt4 key购买 nike

我使用 ConstraintLayout 创建了一个注册表单。这包含垂直堆叠的 EditText 字段。前三个 EditText 显示正常,我可以在 SoftKeyboard 可见时键入它们。但是,对于其他 EditText 字段,它们完全隐藏在 SoftKeyboard 后面。

以下是我遇到此问题的布局 XML 文件。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:isScrollContainer="true"
android:verticalScrollbarPosition="left"
android:fitsSystemWindows="false"
tools:context="com.RegisterWithEmailActivity">

<EditText
android:id="@+id/edtRegFirstName"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="108dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintName"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/edtRegUserName"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="Username"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtRegFirstName" />

<EditText
android:id="@+id/edtRegPassword"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintPassword"
android:inputType="textPassword"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtRegUserName" />

<EditText
android:id="@+id/edtStreetAddress1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintStreetAdd1"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtRegPassword" />

<EditText
android:id="@+id/edtStreetAddress2"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintStreetAdd2"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtStreetAddress1" />

<EditText
android:id="@+id/edtCity"
android:layout_width="109dp"
android:layout_height="36dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintCity"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintHorizontal_bias="0.247"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtStreetAddress2" />

<EditText
android:id="@+id/edtState"
android:layout_width="113dp"
android:layout_height="36dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintState"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.116"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toEndOf="@+id/edtCity"
app:layout_constraintTop_toBottomOf="@+id/edtStreetAddress2" />

<EditText
android:id="@+id/edtZipCode"
android:layout_width="110dp"
android:layout_height="36dp"
android:layout_marginEnd="188dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintZipCode"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtCity" />

<EditText
android:id="@+id/edtGender"
android:layout_width="112dp"
android:layout_height="36dp"
android:layout_marginEnd="60dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="@string/hintGender"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.875"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toEndOf="@+id/edtZipCode"
app:layout_constraintTop_toBottomOf="@+id/edtState" />

<EditText
android:id="@+id/edtRegEmailAddress"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_edittext"
android:ems="10"
android:hint="Email Address"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/textColor"
android:textColorHint="@color/textColor"
android:textSize="20sp"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtGender" />

<Button
android:id="@+id/btnRegisterWithEmail"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_marginTop="12dp"
android:backgroundTint="@color/colorLoginButton"
android:elevation="@android:dimen/app_icon_size"
android:gravity="center"
android:padding="10dp"
android:text="REGISTER"
android:textColor="@color/white"
android:textSize="20sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edtRegEmailAddress" />

</android.support.constraint.ConstraintLayout>

这是 AndroidManifest.xml fragment ,其中对 SoftKeyboard 进行了一些调整。

<activity
android:name=".RegisterWithEmailActivity"
android:isScrollContainer="false"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:windowSoftInputMode="adjustResize|adjustPan"></activity>

最佳答案

Try using Scrollview with only one child layout. and then place your edit text's and buttons under that child layout.

关于android - SoftKeyboard 与 EditText 重叠 - ConstraintLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54665342/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com