简体   繁体   English

Droid上的屏幕键盘出现问题

[英]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. 因此,在对我的moto机器人进行测试时,我面临一个奇怪的问题-当我触摸输入字段(位于屏幕的下端)时,屏幕上的键盘会弹出并隐藏该输入字段。 So user have to enter blindly. 因此用户必须盲目输入。 So is this a sdk issue OR it is particular for droids OR am i doing something wrong??? 那么这是SDK的问题,还是droid特有的问题,或者我做错了什么???

I have tested this same form on G1, Hero..i see no issues at all. 我已经在G1英雄(H1)上测试了相同的表格。我什么都没看到。 Please help... 请帮忙...

Layout xml file -- ` 布局xml文件-`

    <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. 我只想说我有EXACT SAME问题,而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. 在此之前,我在底部固定了一个EditText字段,但是当输入焦点时,键盘将启动并覆盖我的字段。 Also, the available view that is scrollable didn't allow me to see either the absolute TOP or absolute BOTTOM of my scrollable view. 另外,可滚动的可用视图不允许我看到可滚动视图的绝对TOP或绝对BOTTOM。 It just seemed like the view wasn't resizing correctly. 好像视图的大小没有正确调整。

Thanks to synic 感谢Synic

Have you tried putting adding below to the @+id/textmsg 您是否尝试过将以下内容添加到@ + 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 我认为您想要: 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. 诸如<activity android:softInputMode="adjustPan" android:name... />将使Android尝试将当前关注的输入字段平移到视图中,或者您可以使用adjustResize使其尝试调整整个布局的大小以适合键盘(这要求您的布局具有可以调整大小的ListViewScrollView

Try enclosing your RelativeLayout inside a ScrollView. 尝试将RelativeLayout包含在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. 我是这种环境的新手,所以也许这是更好的方法,但这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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