簡體   English   中英

Android軟鍵盤隱藏拆分欄

[英]Android soft keyboard hides split bar

我有一個在運行時加載片段的活動。 當我啟動應用程序時,活動將加載一個帶有EditText的片段。 我將ActionBarSherlock與splitActionBarWhenNarrow一起使用,所以我有一個拆分條(屏幕底部的操作條)。 當EditText成為焦點並加載了軟鍵盤時,它將移到拆分欄的頂部,將其隱藏。 在操作欄上,我還使用NAVIGATION_MODE_LIST,並使用下拉菜單加載另一個片段。 當我加載另一個片段時,即使我轉到另一個片段,下部操作欄也會正確顯示在軟鍵盤的頂部,在該處它可以正常工作。 我將添加一些屏幕截圖來清除它:

第一個片段加載器,使用軟鍵盤無法查看拆分條

在此處輸入圖片說明

使用操作欄導航加載第二個片段之后

在此處輸入圖片說明

重新加載另一個片段,操作欄仍然可見

在此處輸入圖片說明

我嘗試使用最少的代碼測試項目,只是為了加載片段,並且行為是相同的,拆分欄被軟鍵盤隱藏。 如何使其從一開始就顯示拆分欄?

編輯: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" />

您是否嘗試過在顯示輸入法之后立即向主線程發布布局請求? 您可以通過覆蓋根ViewonSizeChanged()回調來確定是否顯示/隱藏輸入法。 作為一個骯臟的概念證明,您可以在給定的持續時間之后發布該布局請求(確保事先顯示輸入方法)。

你也可以使用ViewServer運行hierarchyviewer 您的設備上,而不是仿真器 ,以確定哪些View s為存在(即,如果考生被覆蓋拆分操作欄)。 不過,根據我的記憶,候選視圖還是添加到了包含KeyboardView的根Dialog中,因此拆分后的操作欄可能就位於空格鍵的下方,而不是候選視圖的下方。

為了實現onSizeChanged() ,必須擴展位於View層次結構根目錄的ViewGroup類。 例如,您可能將LinearLayout作為根ViewGroup而所有View都是其子級。 然后,您要做的是創建一個名為MyLinearLayout的新類,該類擴展LinearLayout ,將MyLinearLayout作為xml文件的根View ,然后實現onSizeChanged()回調。 顯示輸入法后,系統將調用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM