RecyclerView in Android app moves up at the same time with keyboard

Viewed 4

I'm developing an android app with Java and, when I click into a TextField, the keyboard moves up and so the RecycleView at the bottom. I was inspired from a video that I watched and so there might be something I'm not considering (here's the link of the video): https://www.youtube.com/watch?v=q7NF-2gtfEU&ab_channel=GeeksforGeeks

How can I solve this (Pictures of the problem below):enter image description here

layout of the Activity:

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

<RelativeLayout 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"
    tools:context=".MainActivity">

    <include
        android:id="@+id/mytoolbar"
        layout="@layout/toolbar"
        />
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/idRLHome"
        android:visibility="visible"
        android:layout_below="@id/mytoolbar"
        >

        <ImageView
            android:id="@+id/idIVBack"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@color/teal_700" />

        <TextView
            android:id="@+id/idTVCityName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="20dp"
            android:text="City Name"
            android:textAlignment="center"
            android:textColor="@color/white"
            android:textSize="18sp"
            />

        <LinearLayout
            android:id="@+id/idLLEdt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/idTVCityName"
            android:orientation="horizontal"
            android:weightSum="5"
            >

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/idTIL"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="4.5"
                android:background="@android:color/transparent"
                android:hint="Enter City Name"
                android:padding="5dp"
                android:textColorHint="@color/white"
                app:hintTextColor="@color/white">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/idEdtCity"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@color/teal_700"
                    android:importantForAutofill="no"
                    android:inputType="text"
                    android:singleLine="true"
                    android:textColor="@color/white"
                    android:textSize="14sp" />

            </com.google.android.material.textfield.TextInputLayout>

            <ImageView
                android:id="@+id/idIVSearch"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="10dp"
                android:layout_weight="0.5"
                android:background="@android:color/transparent"
                android:src="@drawable/ic_search"
                app:tint="@color/white" />

        </LinearLayout>

        <TextView
            android:id="@+id/idTVTemperature"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/idLLEdt"
            android:layout_margin="10dp"
            android:gravity="center_horizontal"
            android:padding="5dp"
            android:text="23"
            android:textColor="@color/white"
            android:textSize="70dp"
            />

        <ImageView
            android:id="@+id/idIVIcon"
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:layout_below="@id/idTVTemperature"
            android:layout_centerHorizontal="true"
            android:layout_marginStart="10dp"
            android:src="@mipmap/ic_launcher" />

        <TextView
            android:id="@+id/idTVCondition"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/idIVIcon"
            android:layout_marginStart="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginBottom="10dp"
            android:gravity="center"
            android:padding="5dp"
            android:text="Condition"
            android:textAlignment="center"
            android:textColor="@color/white" />

        <TextView
            android:id="@+id/idTVHumidity"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/idTVCondition"
            android:layout_marginStart="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginBottom="10dp"
            android:gravity="center"
            android:padding="5dp"
            android:text="Condition"
            android:textAlignment="center"
            android:textColor="@color/white" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/idRvWeather"
            android:layout_margin="8dp"
            android:text="This Week's Weather Forecast"
            android:textColor="@color/white"
            android:textStyle="bold"
            />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/idRvWeather"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            />


    </RelativeLayout>
    
</RelativeLayout>
0 Answers
Related