Android软键盘隐藏分割条

时间:2012-11-08 13:48:09

标签: android android-layout

我有一个在运行时加载片段的活动。当我启动应用程序时,活动会加载带有EditText的片段。我使用ActionBarSherlock和splitActionBarWhenNarrow,所以我有一个分割栏(屏幕底部的动作栏)。当EditText获得焦点并加载软键盘时,它会在分割栏的顶部进行隐藏。在操作栏上我也使用了NAVIGATION_MODE_LIST,我使用下拉菜单加载另一个片段。当我加载另一个片段时,下方操作栏正确显示在软键盘顶部,即使我转到另一个片段,它仍然正常工作。我将添加一些截图来清除它:

第一个片段加载器,分离条不可与软键盘接触

enter image description here

使用操作栏导航

加载第二个片段后

enter image description here

重新加载另一个片段,操作栏仍然可见

enter image description here

我尝试使用最少代码的测试项目来加载片段并且行为相同,分割条被软键盘隐藏。 如何让它从头开始显示分割栏?

编辑:android:windowSoftInputMode =“adjustResize”不会改变此行为中的任何内容

活动布局:

<it.bem.remailr.MyFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:orientation="horizontal"
android:background="@drawable/bg_no_repeat"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

片段布局:

<it.bem.remailr.MyRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<EditText
    android:id="@+id/editText1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="top|left"
    android:inputType="textMultiLine|textNoSuggestions"
    android:windowSoftInputMode="adjustPan"
    android:background="#00000000"
    android:hint="@string/text_hint"
    android:scrollHorizontally="false" >
</EditText>

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" />

1 个答案:

答案 0 :(得分:1)

您是否尝试在显示输入法后立即向主线程发布布局请求?您可以通过覆盖根onSizeChanged()中的View回调来确定是否显示/隐藏输入法。作为一个肮脏的概念证明,您可以在给定的持续时间后发布该布局请求(确保您事先显示输入方法)。

您还可以使用ViewServer在您的设备上运行hierarchyviewer ,而不是模拟器,以确定存在View的内容(即,如果候选人覆盖分裂行动栏)。从我记得的情况来看,候选视图被添加到包含Dialog的根KeyboardView中,所以很可能拆分动作栏就在空格键下面,而不是在候选人观点。

为了实现onSizeChanged(),您必须扩展位于ViewGroup层次结构根目录的View类。例如,您的根LinearLayout可能有ViewGroup,而您View的所有MyLinearLayout都属于此LinearLayout。然后你要创建一个名为MyLinearLayout的新类,它扩展View,将onSizeChanged()作为根{{1}}放在xml文件中,然后实现{{1}} } 打回来。当输入方法显示时,系统将调用它。

相关问题