1

The soft keyboard covers up my EditText fields when attempting to type into the EditText.

How can i prevent the soft keyboard from covering up my EditText fields?

After pressing the back button i can see what i typed, because the soft keyboard is no longer covering the EditText.

I am using the galaxy 10.1 inch tablet.

XML

<ScrollView
            android:layout_width="wrap_content"
            android:layout_height="400dp" >

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="1) Project"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/projectET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:textSize="25sp"
                        android:ems="10"
                        android:hint="Project" 
                        android:inputType="textCapWords"
                        android:layout_gravity="bottom"/>

                    <CheckBox
                        android:id="@+id/projectCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="2) Customer"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/customerET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:inputType="textCapWords"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:hint="Customer" />

                    <CheckBox
                        android:id="@+id/customerCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:id="@+id/material1"
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="3) Material"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/materialET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:textSize="25sp"
                        android:layout_gravity="bottom"
                        android:inputType="textCapWords"
                        android:ems="10"
                        android:hint="Material" />

                    <CheckBox
                        android:id="@+id/materialCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="4) Phase"
                        android:layout_gravity="bottom"
                        android:textColor="#000000"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/fazeET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="Phase" />

                    <CheckBox
                        android:id="@+id/fazeCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="5)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="6)"
                        android:layout_gravity="bottom"
                        android:textColor="#000000"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="7)"
                        android:layout_gravity="bottom"
                        android:textColor="#000000"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="8)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="55dp"
                        android:layout_height="wrap_content"
                        android:enabled="false" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="9)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="55dp"
                        android:layout_height="wrap_content"
                        android:enabled="false" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="10)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="55dp"
                        android:layout_height="wrap_content"
                        android:enabled="false" />
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
prolink007
  • 33,872
  • 24
  • 117
  • 185
Michael Zeuner
  • 1,736
  • 3
  • 15
  • 23
  • possible duplicate of [Android soft keyboard covers edittext field](http://stackoverflow.com/questions/3295672/android-soft-keyboard-covers-edittext-field) – prolink007 Aug 09 '12 at 14:14
  • I added the exact attribute you need to add to your `Activity` for this to work. Please view the edit to my answer. – prolink007 Aug 09 '12 at 14:38

2 Answers2

5

You need to use the windowSoftInputMode. This will allow your UI to resize when the keyboard comes up. Allowing the user to see the EditText while typing in the keyboard.

Add this attribute in your AndroidManifest.xml to your Activity.

android:windowSoftInputMode="adjustPan"

Reference

Community
  • 1
  • 1
prolink007
  • 33,872
  • 24
  • 117
  • 185
0

Well, I think you have some fixed layout above your ScrollView, because usually the ScrollView would automatically scroll to the Focused component.

So, if I am right, there is two options (that I know):

  1. Bring the ScrollView over the keyboard or
  2. Verify layout changes to dynamically bring ScrollView to an upper and visible position, after ScrollView is visible it will automatically show the right EditText to the user.
prolink007
  • 33,872
  • 24
  • 117
  • 185
Pozzo Apps
  • 1,859
  • 2
  • 22
  • 32
  • Do you think you could farther explain to me how I would go about doing the second option? – Michael Zeuner Aug 09 '12 at 14:21
  • You will need to override the main view from your layout and on method onMeasure() you will receive calls when your layout is resized, than you can callback your activity to reposition your view, but dont forget to undo it latter..... In my case I did it whenever I had a too small view, so in devices with smaller screen I remove all uneeded componnets. – Pozzo Apps Aug 09 '12 at 14:50