为什么键盘会在TabBar后出现?

6

在我的应用程序中有标签栏和编辑框。

请参见下面的图片:

正常屏幕:

enter image description here

按下编辑框后的图片:

enter image description here

现在为什么这个标签栏会随着键盘而上移呢?我希望它保持在底部,即使用户通过点击编辑文本来打开键盘。

那么我应该怎么做呢?

请帮助我解决这个问题。

我的TabBarMain活动的XML布局如下:

    <?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="wrap_content"
    >

    <LinearLayout
        android:id="@+id/LL1"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >

       <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            />

      <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_gravity="bottom"
            android:layout_weight="0"/>

    </LinearLayout>

</TabHost> 

所以请帮助我完成这项任务。谢谢。

1
在添加了 adjustPan 之后,你的 EditTextView 不会从屏幕顶部消失了吗?请告诉我你是如何解决这个问题的。 - Anuj
我已经尝试了您接受的解决方案,但它也隐藏了我的意思是向上移动布局。这对我很紧急....如何解决这个问题??? - Developer
3个回答

13
请使用这个。
android:windowSoftInputMode="adjustPan"

在 Android 的清单文件中指定你的活动。

例如:

<activity
            android:name="Youractivity"
            android:windowSoftInputMode="adjustPan"/>

2

请在TabHost中设置以下内容:

android:isScrollContainer="false"

1

在您的清单文件中为 activity 属性 windowsoftinputmode 添加 stateUnchanged,如下所示:

 <activity android:name="Youractivity"
        android:windowSoftInputMode="stateUnchanged"/>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接