简体   繁体   中英

Problem with onscreen keyboard on Droid

i am developing an application which has a general text entry form. So while testing on my moto droid, i am facing a strange issue-- when i touch an input field ( which is at lower end of the screen) -- the on screen keyboard pops up and hides the input field. So user have to enter blindly. So is this a sdk issue OR it is particular for droids OR am i doing something wrong???

I have tested this same form on G1, Hero..i see no issues at all. Please help...

Layout xml file -- `

    <TextView android:id="@+id/textmsg" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="Some text"
        android:layout_marginTop="10px" android:textColor="#ffffff"
        android:textSize="15px" android:layout_marginLeft="10px"
        android:layout_marginRight="10px" />

    <EditText android:id="@+id/textstreet1" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginTop="15px"
        android:layout_below="@+id/textmsg" android:textColor="#000000"
        android:textSize="20px" android:gravity="center_vertical"
        android:layout_marginLeft="10px" android:paddingLeft="5px"
        android:layout_marginRight="10px" />

    <EditText android:id="@+id/textstreet2" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginTop="2px"
        android:layout_below="@+id/textstreet1" android:textColor="#000000"
        android:textSize="20px" android:gravity="center_vertical"
        android:layout_marginLeft="10px" android:paddingLeft="5px"
        android:layout_marginRight="10px" />

    <EditText android:id="@+id/textcity" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginTop="2px"
        android:layout_below="@+id/textstreet2" android:textColor="#000000"
        android:textSize="20px" android:gravity="center_vertical"
        android:layout_marginLeft="10px" android:paddingLeft="5px"
        android:layout_marginRight="10px" />

    <EditText android:id="@+id/textstate" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginTop="2px"
        android:layout_below="@+id/textcity" android:textColor="#000000"
        android:textSize="20px" android:gravity="center_vertical"
        android:layout_marginLeft="10px" android:paddingLeft="5px"
        android:layout_marginRight="10px" />

    <EditText android:id="@+id/textzip" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginTop="2px"
        android:layout_below="@+id/textstate" android:textColor="#000000"
        android:textSize="20px" android:gravity="center_vertical"
        android:layout_marginLeft="10px" android:paddingLeft="5px"
        android:layout_marginRight="10px" />

    <EditText android:id="@+id/textcrossstreet"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_marginTop="2px" android:layout_below="@+id/textzip"
        android:textColor="#000000" android:textSize="20px" android:gravity="center_vertical"
        android:layout_marginLeft="10px" android:paddingLeft="5px"
        android:layout_marginRight="10px" />

    <EditText android:id="@+id/textdi" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginTop="2px"
        android:layout_below="@+id/textcrossstreet" android:textColor="#000000"
        android:textSize="20px" android:gravity="center_vertical"
        android:layout_marginLeft="10px" android:paddingLeft="5px"
        android:layout_marginRight="10px" />

</RelativeLayout>

`

I just want to say that I had the EXACT SAME problem and the solution "for me" was given by synic. I had to update my manifest with the following:

<activity android:name=".MyActName" android:softInputMode="adjustResize" ... />

Prior to this, I had a EditText field anchored to the bottom, but when focus is entered, the keyboard would launch and cover my field. Also, the available view that is scrollable didn't allow me to see either the absolute TOP or absolute BOTTOM of my scrollable view. It just seemed like the view wasn't resizing correctly.

Thanks to synic

Have you tried putting adding below to the @+id/textmsg

android:layout_gravity="top"

or try using a linearlayout instead of a relativelayout. It doesn't seem like you need a relative layout since all of the items are being stacked vertically.

I think you want: https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

You can specify which softinput method your activity uses in your manifest.

Something like <activity android:softInputMode="adjustPan" android:name... /> will make Android try to pan the currently focused input field into view, or you can use adjustResize to have it try to resize the entire layout to fit the keyboard (this requires that your layout has a ListView or a ScrollView that can be resized.

Try enclosing your RelativeLayout inside a ScrollView. THen you just scroll up and down to the fields you want to edit. I do have a problem with right now that I'm looking for an answer, the top item is half hidden under the Screen title, but I don't think it's an issue with what I suggested.

The behaviour you're getting is sort of necessary. There may be a phone without a keyboard. I did notice that if you go to landscape, the keyboard goes away. Guess they assume that in Landscape mode, the physical keyboard will be there.

I'm new to this environment, so maybe thre are better ways, but this is working for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM