【问题标题】:Android Tabhost keyboard overlaps inputsAndroid Tabhost 键盘重叠输入
【发布时间】:2012-11-26 18:56:03
【问题描述】:

我有 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>

【问题讨论】:

    标签: android keyboard android-tabhost


    【解决方案1】:

    当键盘弹出时,它具有“两种视觉模式”。全屏,这意味着键盘呈现的窗口完全覆盖您的应用程序或不是全屏。

    在第二种情况下,显示活动的窗口会调整大小。通过这种调整大小,我假设 TabHost 确实会放大,但子布局(在您的表单中)的缩放方式与它们是独立布局的方式不同。

    Android 文档指出,使用 EditText 的应用程序应注意:

    • 在可编辑文本视图中正确设置 inputType,以便 输入法将有足够的上下文来帮助用户输入 文本到他们。
    • 处理输入时丢失屏幕空间的问题 显示方法。理想情况下,应用程序应该处理它的窗口 被调整为更小,但它可以依赖于系统执行 如果需要,可以平移窗口。你应该设置 您的活动或相应的 windowSoftInputMode 属性 您创建的窗口上的值以帮助系统确定是否 平移或调整大小(它会尝试自动确定这一点,但可能 弄错了)。
    • 您还可以控制首选软输入状态 (打开,关闭等)为您的窗口使用相同的 windowSoftInputMode 属性。

    【讨论】:

    • 感谢您的回复。是的,我尝试将 windowSoftInputMode 设置为所有可能的值,但没有成功。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-31
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多