Lucas Fernando Amorim
Lucas Fernando Amorim

Reputation: 121

Soft Keyboard comes over the EditText

I am using Eclipse ADT to develop an Android application. When focus comes over one of the EditText(at lower end of page) the keypad covers the EditText so when I am keying text, I can't see what's being keyed in. What are my options ?

Layout of Index Activity

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="#a8e8f0" android:orientation="vertical" android:id="@+id/layout">
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/welcome_background">
        <include layout="@layout/top"></include>
        <RelativeLayout android:layout_height="wrap_content"
            android:layout_width="fill_parent" android:gravity="center">
            <LinearLayout android:layout_width="270dp"
                android:orientation="vertical" android:layout_height="wrap_content"
                android:id="@+id/body">
                <ImageView android:layout_width="wrap_content" android:src="@drawable/welcome_title" android:layout_height="wrap_content" android:id="@+id/title" style="@style/Theme.Connector.ImageElement"></ImageView>
                <TextView android:text="@string/welcome_text" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/txt_welcome" style="@style/Theme.Connector.FormText"></TextView>
                <Spinner android:layout_width="fill_parent"
                    android:layout_height="wrap_content" style="@style/Theme.Connector.WelcomeSpinner"
                    android:layout_weight="1" android:id="@+id/spinner_isp" />
                <EditText android:layout_height="wrap_content" android:singleLine="true"
                    style="@style/Theme.Connector.WelcomeInput" android:hint="@string/txt_user"
                    android:layout_width="fill_parent" android:id="@+id/edit_user"></EditText>
                <EditText android:layout_alignParentLeft="true"  android:singleLine="true"
                    android:layout_height="wrap_content" style="@style/Theme.Connector.WelcomeInput"
                    android:hint="@string/txt_password" android:layout_width="fill_parent"
                    android:password="true" android:id="@+id/edit_password"/>
                <LinearLayout android:layout_width="fill_parent"
                    android:orientation="horizontal" android:layout_height="fill_parent"
                    android:id="@+id/frm_action">
                    <Button style="@style/Theme.Connector.Button"
                        android:layout_height="wrap_content" android:layout_width="100dp"
                        android:text="@string/btn_cancel" android:layout_weight="1"
                        android:id="@+id/btn_cancel" />
                    <Button android:text="@string/btn_continue"
                        android:layout_height="wrap_content" android:layout_width="100dp"
                        style="@style/Theme.Connector.ButtonContinue"
                        android:layout_weight="1" android:id="@+id/btn_continue"></Button>
                </LinearLayout>
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="vex.connector" android:versionCode="1" android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application android:icon="@drawable/icon" android:label="@string/app_name"
        android:theme="@style/Theme.Connector">

        <activity android:name=".IndexActivity" android:label="@string/app_name"
            android:screenOrientation="portrait" android:windowSoftInputMode="stateVisible|adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name=".WiFiBroadcastReceiver">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>

    </application>
</manifest>

Keyboard

keyboard

Upvotes: 2

Views: 7818

Answers (3)

SoftDesigner
SoftDesigner

Reputation: 5853

If none of these answers help make sure your style doesn't set this attribute:

<item name="android:windowTranslucentStatus">true</item>

If so, override the style for your activity.

Upvotes: 1

Keiran Russell
Keiran Russell

Reputation: 15

I had the exact same issue and i found tarkeshwar's approach to be better.

What happens if you set android:windowSoftInputMode="adjustResize" instead of adjustPan that you have currently? Also, are you using Fullscreen style (android:windowFullscreen)? Only today I had similar softkeyboard overlap problem. Using adjustResize and getting rid of Fullscreen style fixed it.

tarkeshwar

Upvotes: 1

Squonk
Squonk

Reputation: 48871

Wrap your outer LinerLayout in a ScrollView, e.g.,

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    ...

    <!-- Your current layout here -->

</ScrollView>

This should allow scrolling your layout to see the lower EditText

Upvotes: 9

Related Questions