2

我有 tabhost 布局,我在其中加载我的表单活动(滚动条中有 10 个输入)。当我开始在最底部的输入上键入时,显示的键盘和未显示的焦点输入(键盘与输入重叠而不是正常滚动)并且我看不到我在输入什么。当我尝试在 tabhost 之外运行表单活动时,一切正常,我可以键入并查看始终聚焦的输入。我的最低 API 级别为 10,最高为 17。

任何帮助或方向高度赞赏。

TabHost 布局:

<?xml version="1.0" encoding="UTF-8"?>
<TabHost 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

   <RelativeLayout
       android:id="@+id/layTab"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
       android:layout_centerVertical="true"
       android:gravity="center"
       android:background="#00A99D"
       android:paddingLeft="0dip"
       android:paddingRight="0dip" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:gravity="center|bottom"                
            android:padding="0dip" />

    </RelativeLayout>
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_above="@id/layTab"/>
</RelativeLayout>

表格布局:

<?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:orientation="vertical">

 <ScrollView 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#eee"
    android:padding="0dip"
    android:layout_alignParentBottom="true">   
<LinearLayout
    android:id="@+id/body"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/header"
    android:orientation="vertical" >

<EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:hint="1"
            android:ems="10" />

         <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:hint="2"
            android:ems="10" />             

         <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:hint="3"
            android:ems="10" />    

         <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:hint="4"
            android:ems="10" />    

         <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:hint="5"
            android:ems="10" />    

         <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="6"
            android:ems="10" />    

         <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="7"
            android:ems="10" />    

         <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="8"
            android:ems="10" />    

            <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:imeOptions="flagNoExtractUi"
            android:hint="9"
            android:ems="10"/>



               <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="10"
            android:ems="10" />    

    </LinearLayout>

</ScrollView>

 </LinearLayout>
4

1 回答 1

1

When a keyboard pops up, it has 'two visual modes'. FullScreen, meaning that the window in which the keyboard renders is fully overlaying your application or not fullscreen.

In the second case the window, in which your activity displays, is resized. With this resizing, I assume that a TabHost does scale up but the child layouts (in the case your form) are not scaled the same way as if they would be a stand-alone layout.

The Android documentation states that an application using an EditText should be aware of:

  • Properly set the inputType in your editable text views, so that the input method will have enough context to help the user in entering text into them.
  • Deal well with losing screen space when the input method is displayed. Ideally an application should handle its window being resized smaller, but it can rely on the system performing panning of the window if needed. You should set the windowSoftInputMode attribute on your activity or the corresponding values on windows you create to help the system determine whether to pan or resize (it will try to determine this automatically but may get it wrong).
  • You can also control the preferred soft input state (open, closed, etc) for your window using the same windowSoftInputMode attribute.
于 2012-11-26T09:43:53.220 回答