gpt4 book ai didi

Android Tabhost 键盘重叠输入

转载 作者:行者123 更新时间:2023-11-29 01:59:09 24 4
gpt4 key购买 nike

我有 tabhost 布局,我在其中加载我的表单 Activity (滚动条中有 10 个输入)。当我开始在最底部的输入上打字时,显示的键盘和未显示的焦点输入(键盘与输入重叠而不是正常滚动)并且我看不到我在输入什么。当我尝试在 tabhost 之外运行表单 Activity 时,一切正常,我可以键入并始终查看输入。我的最低 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>

最佳答案

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

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

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

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

关于Android Tabhost 键盘重叠输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13561949/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com