Home > Blockchain >  How can I swipe up activity when the keyboard is open?
How can I swipe up activity when the keyboard is open?

Time:11-02

Keyboard conflicts with email EditText on login page. I want to swipe above Welcome back and description text when keyboard open.

Current state: https://i.hizliresim.com/135sizd.png What do I want: https://i.hizliresim.com/pgacbn2.png

I used adjustpan and adjustresize but it didn't work. I'm waiting for your help. Thank you.

Here is my XML code.

<?xml version="1.0" encoding="utf-8"?>

<androidx.coordinatorlayout.widget.CoordinatorLayout 
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:padding="15dp"
android:background="@color/main_bg"
tools:context=".ui.auth.LoginActivity">

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:isScrollContainer="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:fontFamily="@font/i_d_semibold"
            android:letterSpacing="-0.001"
            android:text="@string/login_header"
            android:textColor="@color/header"
            android:textSize="22sp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:fontFamily="@font/i_d_light"
            android:text="@string/login_description"
            android:textColor="@color/description"
            android:textSize="14sp"
            android:textStyle="bold" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="47dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/input_bg"
            android:drawableStart="@drawable/mail_ic"
            android:drawableEnd="@drawable/check_ic"
            android:drawablePadding="20dp"
            android:fontFamily="@font/i_d_regular"
            android:hint="@string/email"
            android:inputType="textEmailAddress"
            android:paddingStart="20dp"
            android:paddingEnd="20dp"
            android:textColor="@color/header"
            android:textColorHint="@color/description"
            android:textSize="14sp" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="47dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/input_bg"
            android:drawableStart="@drawable/password_ic"
            android:drawableEnd="@drawable/eye_ic"
            android:drawablePadding="20dp"
            android:fontFamily="@font/i_d_regular"
            android:hint="@string/password"
            android:inputType="textPassword"
            android:paddingStart="20dp"
            android:paddingEnd="20dp"
            android:textColor="@color/header"
            android:textColorHint="@color/description"
            android:textSize="14sp" />



    </LinearLayout>

</androidx.core.widget.NestedScrollView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
        android:layout_width="250dp"
        android:textSize="13sp"
        android:layout_height="wrap_content"
        android:text="@string/terms_of_service"
        android:textColor="@color/description"
        android:gravity="center" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1"
        android:layout_marginBottom="10dp"
        android:gravity="center" >

        <com.google.android.material.button.MaterialButton
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:layout_marginTop="10dp"
            app:cornerRadius="10dp"
            android:text="@string/get_started"
            android:textColor="@color/white"
            android:layout_weight="0.45"
            app:strokeColor="@color/white"
            android:fontFamily="@font/i_d_semibold"
            android:textAllCaps="false"
            android:letterSpacing="-0.001"
            app:strokeWidth="2dp"
            app:backgroundTint="@color/main_bg"
            />

        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0.02" />

        <com.google.android.material.button.MaterialButton
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:layout_marginTop="10dp"
            app:cornerRadius="10dp"
            android:layout_weight="0.45"
            android:text="@string/login"
            android:fontFamily="@font/i_d_bold"
            android:textAllCaps="false"
            android:letterSpacing="-0.001"
            app:backgroundTint="@color/main_button"
            />

    </LinearLayout>

</LinearLayout>


</androidx.coordinatorlayout.widget.CoordinatorLayout>

CodePudding user response:

add for your activity in manifest file

<activity
    ...
    android:windowSoftInputMode="adjustResize">
    ...
</activity>

CodePudding user response:

Add in AndroidManifest.xml

android:windowSoftInputMode="adjustPan|adjustResize"

Make changes in your onCreate() method in the activity class like


getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
  • Related