I am using ConstraintLayout
in my application.
When soft keyboard is shown, I want to only button move above that And other items do not move up. I did this with using a scrollView
.
Now I used guideLine
to support all screen sizes, but after soft keyboard is shown, all items move to up again.
How should I use guideLine
for this?
Manifest :
<activity
android:name=".RegisterActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize" />
<activity
Xml :
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/button_register_sendVerification"
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_register_topParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.04" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_register_bottomParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.96" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_register_leftParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.08" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_register_rightParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.92" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_register_topMobileNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.4"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_register_bottomMobileNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.49"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout_register_mobileNumber"
style="@style/TextInputLayout.All"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintLeft_toRightOf="@id/guideline_register_leftParent"
app:layout_constraintRight_toLeftOf="@id/guideline_register_rightParent"
app:layout_constraintTop_toTopOf="@+id/guideline_register_topMobileNumber"
app:layout_constraintBottom_toBottomOf="@id/guideline_register_bottomMobileNumber">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/textInputEditText_register_mobileNumber"
style="@style/TextInputEditText.All"
android:hint="@string/text_all_enterPhoneNumber"
android:inputType="phone"
android:maxLength="11"
android:textAlignment="center" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<Button
android:id="@+id/button_register_sendVerification"
style="@style/Button.all"
android:layout_width="0dp"
android:layout_height="48dp"
android:text="@string/text_button_registerActivity_sendVerification"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>