0

My code is as below:

activity_payment.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:orientation="vertical">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar_base" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/toolbar">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/textCard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="19dp"
                android:layout_marginTop="20dp"
                android:text="Credit card"
                android:textAllCaps="true"
                android:textColor="@color/colorFuscousGray"
                android:textSize="18sp" />

            <EditText
                android:id="@+id/cardName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textCard"
                android:layout_marginLeft="19dp"
                android:layout_marginRight="19dp"
                android:layout_marginTop="25dp"
                android:hint="Name on card"
                android:maxLines="1"
                android:minLines="1"
                android:singleLine="true"
                android:textColorHint="@color/colorSilverChaliceac"
                android:textSize="13sp" />

            <EditText
                android:id="@+id/cardNumber"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cardName"
                android:layout_marginLeft="19dp"
                android:layout_marginRight="19dp"
                android:layout_marginTop="25dp"
                android:hint="Credit card number xxxx-xxxx-xxxx-xxxx"
                android:inputType="phone"
                android:maxLength="19"
                android:maxLines="1"
                android:minLines="1"
                android:singleLine="true"
                android:textColorHint="@color/colorSilverChaliceac"
                android:textSize="13sp" />

            <RelativeLayout
                android:id="@+id/expiryLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cardNumber"
                android:layout_marginTop="25dp">

                <EditText
                    android:id="@+id/expiry"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_marginLeft="19dp"
                    android:hint="Expiry MM/YY"
                    android:inputType="numberDecimal"
                    android:maxLength="5"
                    android:maxLines="1"
                    android:minLines="1"
                    android:singleLine="true"
                    android:textColorHint="@color/colorSilverChaliceac"
                    android:textSize="13sp" />

                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true">

                    <ImageView
                        android:layout_width="34dp"
                        android:layout_height="21dp"
                        android:layout_gravity="start"
                        android:src="@drawable/icon_card" />

                    <EditText
                        android:id="@+id/cvv"
                        android:layout_width="93dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="19dp"
                        android:gravity="right"
                        android:hint="CVV"
                        android:inputType="numberDecimal"
                        android:maxLength="3"
                        android:maxLines="1"
                        android:minLines="1"
                        android:singleLine="true"
                        android:textColorHint="@color/colorSilverChaliceac"
                        android:textSize="13sp" />

                </FrameLayout>
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/expiryLayout"
                android:layout_marginTop="15dp">

                <CheckBox
                    android:id="@+id/checkBox1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:layout_marginLeft="19dp"
                    android:text="Save this card"
                    android:textColor="@color/colorFuscousGray"
                    android:textSize="15sp" />

            </RelativeLayout>
        </RelativeLayout>

    </ScrollView>

    <RelativeLayout
        android:id="@+id/payLayout"
        android:layout_width="match_parent"
        android:layout_height="53dp"
        android:layout_alignParentBottom="true"
        android:background="@color/colorRoyalPurple">

        <TextView
            android:id="@+id/payButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Pay"
            android:textAllCaps="true"
            android:textColor="@android:color/white" />
    </RelativeLayout>

</RelativeLayout>

toolbar_base.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"
    app:contentInsetStartWithNavigation="0dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:background="@drawable/gradient_titlebar">


        <ImageView
            android:id="@+id/backArrow"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_centerVertical="true"
            android:src="@drawable/ic_back_arrow" />

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/backArrow"
            android:textColor="@android:color/white"
            android:textSize="18sp" />

    </RelativeLayout>
</android.support.v7.widget.Toolbar>

AndroidManifest.xml

 <activity
            android:name=".activity.PaymentActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustResize|adjustPan" />

Even after I set all the things, when soft keyboard goes up,it is not able to push the layout upward. Is there anything I am missing?

M thaker
  • 383
  • 1
  • 4
  • 15

2 Answers2

0

Remove "adjustPan"

android:windowSoftInputMode="adjustResize"
0

"adjustResize"

The activity's main window is always resized to make room for the soft keyboard on screen.

"adjustPan"

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

Use adjustResize instead of adjustPan to get your desired effect.

<activity android:windowSoftInputMode="adjustResize"> </activity>
Aldrin Joe Mathew
  • 472
  • 1
  • 4
  • 13