I have an EditText and a button and some other TextViews in a fragment layout.The parent of the layout is Constraint Layout and the activity that holds it is a Relative layout. When the layout is displayed the keyboard is displayed but I want the button to be pushed above the keyboard.I gave the the attribute android:windowSoftInputMode="adjustResize" to the manifest file in the activity that holds the fragment layout.Still did not help me!!I have referred to one of the following links Link1, Link2, bu the answers did not help me...
Manifest:
<activity android:name=".Otp.Otp"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"/>
Activity 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:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/otp_splash"
android:layout_width="match_parent"
android:scaleType="matrix"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@drawable/masked_splash">
</ImageView>
<ImageView
android:layout_width="@dimen/intro_logo_wdth"
android:layout_height="@dimen/intro_logo_hght"
android:background="@drawable/splash_logo"
android:layout_centerHorizontal="true"
android:id="@+id/msked_splsh_logo"
android:layout_marginTop="50dp"/>
<RelativeLayout
android:id="@+id/otp_lyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_below="@+id/msked_splsh_logo"
android:layout_marginTop="45dp">
</RelativeLayout>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_margin="8dp"
android:background="@drawable/close"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Note: In the above layout @+id/otp_lyt is the id where fragment is fragment is loaded.
Fragment_Layout:
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<TextView
android:id="@+id/head"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/ph_verify_lbl_mrgn"
android:text="@string/verify_your_phone_number"
android:textColor="#bb2b67"
android:textSize="@dimen/ph_verify_head_tsxtsze"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:text="@string/lorem_ipsum_lorem_ipsum"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/head" />
<EditText
android:id="@+id/phnmbr"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginEnd="10dp"
android:focusable="true"
android:fitsSystemWindows="true"
android:focusableInTouchMode="true"
android:background="@drawable/edt_txt_bg"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="8dp"
android:hint="@string/ph_hint"
android:inputType="number"
android:textSize="@dimen/ph_verify_head_tsxtsze"
android:paddingTop="40dp"
android:paddingLeft="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<Button
android:id="@+id/next"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="@drawable/button_bg"
android:text="@string/next"
android:textColor="#ffffff"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
<ImageView
android:id="@+id/imageView"
android:layout_width="20dp"
android:layout_height="25dp"
android:elevation="2dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="@drawable/arrow"
app:layout_constraintBottom_toBottomOf="@+id/next"
app:layout_constraintEnd_toEndOf="@+id/next"
app:layout_constraintHorizontal_bias="0.909"
app:layout_constraintStart_toStartOf="@+id/next"
app:layout_constraintTop_toTopOf="@+id/next"
app:layout_constraintVertical_bias="0.571" />
</android.support.constraint.ConstraintLayout>
</layout>
Screenshot1:
Screenshot2:
TEST: Activity 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"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
android:layout_marginTop="100dp"
android:fitsSystemWindows="true">
</RelativeLayout>
</RelativeLayout>
Fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="114dp"
android:ems="10"
android:focusable="true"
android:fitsSystemWindows="true"
android:inputType="textEmailAddress" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Button" />
</RelativeLayout>
Manifest:
<activity android:name=".MainActivity"
android:windowSoftInputMode="adjustResize|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>