3

在Android應用程序,在Android中按下EditText(鍵盤彈出之後)時是否不想隱藏EditText視圖?

當我按的EditText那麼它看起來像如下:

enter image description here

我在清單文件中使用的TextView以上的TabBar和下面的代碼

android:windowSoftInputMode="stateHidden|adjustResize|adjustPan" 

在按下EditText時隱藏標籤。但它也隱藏了文本視圖和按鈕,如下所示:

enter image description here

我不想隱藏textview,我只是想隱藏tabbar。

xml文件

chatroom.xml:

<?xml version="1.0" encoding="utf-8"?> 

<TabHost 
    android:id="@+id/tabHost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

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

      <include layout="@layout/chat_tab_list" /> 
     </FrameLayout> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0" 
      android:windowSoftInputMode="adjustPan" 
      > 
     </TabWidget> 
    </LinearLayout> 
</TabHost> 

chat_tab_list.xml:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    android:id="@+id/chat_list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:visibility="visible" > 

    <ListView 
     android:id="@+id/listView" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:background="@color/white" > 
    </ListView> 

    <LinearLayout 
     android:id="@+id/text_entry" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:orientation="horizontal" 
     android:visibility="visible" > 

     <EditText 
      android:id="@+id/txt_inputText" 
      android:layout_width="125dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.8" 
      android:hint="@string/enter_text" 
      android:inputType="text"     
      android:windowSoftInputMode="adjustResize" /> 

     <Button 
      android:id="@+id/btn_Send" 
      android:layout_width="100dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.2" 
      android:text="@string/send" /> 
    </LinearLayout> 
</LinearLayout> 

請指導我在此。

任何幫助將不勝感激。

+0

我有同樣的問題,你有解決辦法嗎? – Jayesh

回答

2

This question表示您應該只能在標籤欄上設置android:windowSoftInputMode="adjustPan",但不能在文本輸入上設置。這樣,文本輸入行爲正常,向上滾動,但標籤欄保持放置。文本輸入應該有android:windowSoftInputMode="adjustResize",以便它滾動。有關不同模式的詳細信息,請參閱this page

根據您的編輯,它看​​起來像是因爲您的編輯文本位於選項卡窗口小部件內部。您應該使用adjustResize的軟輸入模式將Edit Text外部移動到您的根linearLayout。

+0

在Tabbar上表示:在TabHost或TabWidget上?謝謝。 – Ponting

+0

@Ponting你嘗試了什麼?我沒有模擬器啓動和運行。 – xdumaine

+0

我把TabWidget中的android:windowSoftInputMode =「adjustPan」,EditText中的android:windowSoftInputMode =「adjustResize」和Manifest文件的activity中的android:windowSoftInputMode =「adjustPan」。當我按下EditText時,它隱藏TabBar並且不隱藏鍵盤。但剩下的屏幕也向上一側(如ActionBar從設備的屏幕向上一側走出) – Ponting

1

試試這個

將此添加到您的AndroidManifest只是在有您的標籤的活動。

<activity 
    android:name="YourActivity" 
    android:windowSoftInputMode="adjustPan" > 
</activity> 
+0

我試過了。它沒有工作。它也將TextView和TabBar一起隱藏起來。 – Ponting

+0

請把你的活動佈局xml文件 –

+0

@AT_TB:好吧,我把它放在裏面。請參閱我編輯的問題。 – Ponting

0
<Activity> 
    android:windowSoftInputMode="adjustPan" 
</Activity> 
相關問題