I want to make my activity layout resize when keyboard appears, but at the same time keep its toolbar position unchanged. So far all the screen shifts up, when I click on the edit text and the keyboard appears.
Before keyboard appears:
After keyboard appears, the toolbar isn't visible anymore:
I would like to keep the keyboard in its place and shift below it the image.
I can't just specify in the manifest: android:windowSoftInputMode="adjustNothing"
, because the edit text will not be visible anymore, when the keyboard appears.
So far, I use the following code:
In AndroidManifest.xml:
android:windowSoftInputMode="adjustPan|stateHidden"
In layout:
<?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"
android:background="@android:color/white"
android:clickable="true"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="studentplanner.mobile.yardi.com.studplan.presentation.activities.PersonalInformationActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_and_button_height"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:elevation="4dp"
android:background="@color/main">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/personal_information_text"
android:textColor="@android:color/white"
android:textSize="@dimen/medium2_text_size" />
</android.support.v7.widget.Toolbar>
<ImageView
android:id="@+id/background_container"
android:layout_width="match_parent"
android:layout_height="@dimen/extra_large5_dimen"
android:layout_below="@+id/toolbar"
android:scaleType="center"
android:src="@drawable/userbackground" />
...
Any help is welcomed!