3

I have a editText View near the bottom of my activity. When i click it and the keyboard show, but it block the button below the editText. I use the android:windowSoftInputMode="adjustResize" or "adjustPan" but not work as what i want.

Following with some screenshots:

Original View: Original View

When click the edittext: When click the edittext

The View i want: The View i want

Here is my code:

<include
    android:id="@+id/headerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/section_header" />

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/headerView"
    android:fillViewport="true" >

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

        <com.wom.wom.GTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:gravity="center_horizontal"
            android:text="NOT OUR MEMBER YET?"
            android:textSize="28sp" />

        <com.wom.wom.GTextView
            android:layout_width="200dp"
            android:layout_height="50dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="50dp"
            android:background="@drawable/rounded_corner0"
            android:gravity="center"
            android:text="TAKE THE TOUR"
            android:textSize="18sp" />

        <com.wom.wom.ATextView
            android:id="@+id/join_now"
            android:layout_width="200dp"
            android:layout_height="50dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="50dp"
            android:layout_marginTop="30dp"
            android:background="@drawable/rounded_corner_green"
            android:gravity="center"
            android:text="JOIN NOW"
            android:textColor="#FFF"
            android:textSize="18sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/m_dash_black"
            android:gravity="center_horizontal|bottom"
            android:orientation="horizontal" >

            <com.wom.wom.ATextView
                android:id="@+id/tv_add_card"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginRight="50dp"
                android:gravity="center"
                android:text="ADD CARD"
                android:textColor="@drawable/text_selector_wo"
                android:textSize="22sp" />

            <View
                android:id="@+id/vDottedLine"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="15dp"
                android:background="@drawable/vdash_line2"
                android:layerType="software" />

            <com.wom.wom.ATextView
                android:id="@+id/tv_scan_card"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginLeft="50dp"
                android:gravity="center"
                android:text="SCAN CARD"
                android:textColor="@drawable/text_selector_wo"
                android:textSize="22sp" />
        </LinearLayout>

        <RelativeLayout
            android:id="@+id/add_card"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/card_bg" >

            <EditText
                android:id="@+id/card_number"
                android:layout_width="300dp"
                android:layout_height="50dp"
                android:layout_below="@+id/tv3"
                android:layout_marginLeft="50dp"
                android:layout_marginTop="100dp"
                android:background="#FFF"
                android:hint="14 Digit Number"
                android:paddingLeft="5dp"
                android:textSize="20sp" />

            <EditText
                android:id="@+id/password"
                android:layout_width="300dp"
                android:layout_height="50dp"
                android:layout_below="@+id/card_number"
                android:layout_marginLeft="50dp"
                android:layout_marginTop="20dp"
                android:background="#FFF"
                android:hint="Password"
                android:paddingLeft="5dp"
                android:textSize="20sp" />

            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />

            <com.wom.wom.ATextView
                android:id="@+id/ib_add_card"
                android:layout_width="200dp"
                android:layout_height="50dp"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="20dp"
                android:background="@drawable/rounded_corner_red"
                android:gravity="center"
                android:text="ADD MY CARD"
                android:textColor="#FFF"
                android:textSize="18sp" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/scan_card"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/scan_bg"
            android:visibility="gone" >

            <com.wom.wom.ATextView
                android:id="@+id/ib_scan_card"
                android:layout_width="200dp"
                android:layout_height="50dp"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="20dp"
                android:background="@drawable/rounded_corner_red"
                android:gravity="center"
                android:text="SCAN MY CARD"
                android:textColor="#FFF"
                android:textSize="18sp" />
        </RelativeLayout>
    </LinearLayout>
</ScrollView>

</RelativeLayout>
Danny Ho
  • 149
  • 3
  • 17

1 Answers1

0

You should add this attribute in <activity> tag of manifest file.

<activity
    android:windowSoftInputMode="adjustPan"
    //rest attributes ...
/>

EDIT

If adding adjustPan in manifest doesn't work then add it in java code,

Inside onCreate() method after setting contentView write,

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Apurva
  • 7,871
  • 7
  • 40
  • 59