Android: EditText stays hidden behind the keyboard
Asked Answered
F

2

11

Before writing this question I have read through the following answers/articles:

  1. Android soft keyboard covers edittext field
  2. Android keyboard obscures EditText
  3. http://developer.android.com/resources/articles/on-screen-inputs.html
  4. Soft Keyboard Overlapping with EditText Field

The Android soft keyboard is set by default to pan which means it will keep all the editable regions above the keyboard. However it does not pan enough. When I run it and press the edittext that is close to the bottom of the screen, the keyboard comes up and edittext is moved up but not enough to be able to see what is being typed in it. I have used/tried the following:

  1. android:windowSoftInputMode="adjustPan" in the manifest of the Activity. This made no difference. I have also tried putting values of adjustUnspecified and adjustResize too. None of them works.

  2. <uses-sdk android:minSdkVersion="3" /> in the manifest file. My application is targetted for sdk 2.1 and above. Even though, I tried it and did not work.

  3. Using a ScrollView. Does not work either.

Is there a way to manually manage how much "panning" does a keyboard do when a specific edittext is pressed.

Below is my xml file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:background="#ffffff">       

    <ImageView 
    android:id="@+id/header"
    android:layout_width="320dip"
    android:layout_height="86dip"
    android:background="@drawable/header_bg">
    </ImageView>

    <ImageView 
    android:layout_width="320dip"
    android:layout_height="200dip"
    android:layout_alignParentBottom="true"
    android:background="@drawable/bg1_btm">
    </ImageView>

        <TextView android:text="Hostname" 
        android:id="@+id/lbl_hostname"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/header"/>

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_hostname_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/lbl_hostname"
        android:layout_below="@id/header" />

        <EditText android:text="EditText" 
        android:id="@+id/editText_hostname" 
        android:layout_below="@id/lbl_hostname"  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:maxLength="25">
        </EditText>

        <TextView android:text="Registration URL" 
        android:id="@+id/lbl_registration"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_hostname" />

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_registration_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_hostname"
        android:layout_toRightOf="@id/lbl_registration" />

        <TextView android:text="http://" 
        android:id="@+id/lbl_url_prefiz"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/lbl_registration"
        android:paddingTop="10dip" />

        <EditText android:text="EditText" 
        android:id="@+id/editText_registration" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_toRightOf ="@id/lbl_url_prefiz"
        android:layout_below="@id/lbl_registration">
        </EditText>

        <TextView android:text="Chat" 
        android:id="@+id/lbl_chat"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/editText_registration"/>

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_chat_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/editText_registration"
        android:layout_toRightOf="@id/lbl_chat"/>

        <EditText android:text="EditText" 
        android:id="@+id/editText_chat" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/lbl_chat">
        </EditText>

        <TextView android:text="SSID" 
        android:id="@+id/lbl_ssid"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_chat" />

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_ssid_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_chat"
        android:layout_toRightOf="@id/lbl_ssid"
        />

        <EditText android:text="EditText" 
        android:id="@+id/editText_ssid" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/lbl_ssid"
        android:maxLines="1"
        android:inputType="text"
        android:layout_marginBottom="25dip">
        </EditText> 

        <Button android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/ButtonSave" 
        android:text="Save" 
        android:layout_below="@id/editText_ssid"
        android:layout_alignParentLeft="true">
        </Button>

        <Button android:text="Continue" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:id="@+id/ButtonContinue" 
        android:layout_below="@id/editText_ssid" 
        android:layout_alignParentRight="true">
        </Button>

</RelativeLayout>
Fatally answered 24/6, 2011 at 20:27 Comment(3)
The answer is in this post: #4559867Expressage
Thanks. I have done a work around for now. But will check that out later.Fatally
Not that I know. What I did was just moved the button little up in my app.Fatally
O
8

Try

android:windowSoftInputMode="adjustResize"  

worked fine for me :)

Overture answered 11/12, 2014 at 6:33 Comment(0)
F
6

Try to set your all controls layout heights and widths using fill_parent or match_parent...instead of using hard coded values...

also remove this if you are using this as it might be pushing your app downwards...

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

hope it works...

Fyn answered 9/4, 2013 at 7:19 Comment(2)
Thanks. No longer have the project to try this. However, if it works for anyone else, ill accept it as an answer. Thanks for the help.Fatally
makes it visible but disable scroll view and upper views has some problem with it...Pus

© 2022 - 2024 — McMap. All rights reserved.