ConstraintLayout
を使用してサインアップ画面を設計しています。私はConstraintLayout
をスクロールビューの中に入れました。ユーザは、キーパッドが開いているときでも、コンテンツ全体をスクロールして見ることができるはずである。この機能は、RelativeLayout
を使用しているときに機能しますが、ConstraintLayout
を使用しているときは機能しません。画面の下部にあるビューは、キーパッドの背後に隠れています。以下は私が使っているレイアウトです。キーパッドを開いた状態でスクロールダウンする制約レイアウト
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:paddingTop="23dp"
android:fillViewport="true"
tools:context="com.givhero.activities.LoginActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
tools:context="com.givhero.activities.LoginActivity">
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:src="@drawable/back"
android:tint="@color/colorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp"/>
<TextView
android:id="@+id/regEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:text="@string/sign_up_email"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/titles_lists"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/back"
tools:layout_editor_absoluteX="0dp"/>
<TextView
android:id="@+id/nameEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="@android:color/transparent"
android:gravity="left"
android:hint="Name"
android:textColor="@color/dark"
android:textColorHint="@color/dark"
android:textSize="@dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/regEmail"
/>
<View
android:id="@+id/nameDivider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="@color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nameEditText"
/>
<EditText
android:id="@+id/emailEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="@android:color/transparent"
android:gravity="left"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="@color/dark"
android:textColorHint="@color/dark"
android:textSize="@dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nameDivider"
/>
<View
android:id="@+id/emailDivider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="@color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emailEditText"/>
<Button
android:id="@+id/submitButton"
android:layout_width="0dp"
android:layout_height="62dp"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="@drawable/button_theme"
android:enabled="false"
android:text="@string/sign_up"
android:textColor="#FFFFFF"
android:textSize="@dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emailDivider"
/>
<TextView
android:id="@+id/signUpMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:padding="15dp"
android:text="@string/sign_up_message"
android:textColor="@color/dark80Opacity"
android:textSize="@dimen/medium12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/submitButton"
/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
私はマニフェストに以下を追加しました。
<activity android:name=".activities.EmailSignupActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
</activity>
期待どおりにスクロールしませんが。以下は、私はいくつかのEditText
フィールドの下のテキストとサインアップのボタンを持って見ることができるようにより良く理解
用のスクリーンショットです。私が期待しているのは、キーボードが開いていても、そのテキストを見るためにページの一番下にスクロールできることです。キーパッドは、私はキーボードが開いているときにビューをスクロールすることができません
開いているときに、以下のスクリーンショットを確認してください。
EDIT ねえ、
誰もがこの問題で立ち往生し、答えをここに上陸した場合。私は最終的にそれのための解決策を見つけることができました。私はこの問題の正確な理由を理解することができませんでしたが、何がスクロールしないレイアウトを引き起こしているのか把握することができました。当初、私は上記の行が問題を引き起こしていると私はそれを削除した後、私はスクロールすることができた設計のためのステータスバーを含む画面全体を占有しようとしているとのOnCreate
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
に次のように使用されていますレイアウト。デザインのステータスバーを含む全画面を占めていると、レイアウトがスクロールしない理由がわかりました。
私は試しましたが、まだスクロールしていません – Anu