2012-01-25 24 views
14

我有一堆EditText領域的活動,並將windowSoftInputMode設置爲adjustPan,這主要是做我想要的,但是對於在底部的editText佈局,它不夠平移。它將平移顯示多行編輯文本的第一行,但只要您按下Enter鍵,光標就會沿着一條線向下移動,現在隱藏在鍵盤下方。如何使windowSoftInputMode =「adjustPan」泛更多

是否有反正我可以讓它進一步泛,以便editText的頂部完全位於窗口的頂部。

使用adjustResize絕對不會做我想做的,鍋的正確的事情,只需要它進一步平移。

+0

發佈您的屏幕截圖,以便輕鬆地降低問題 – Lokesh

回答

6

同樣的事情發生在我身上。

我做的解決的是,我只是把所有的控件放在ScrolllView

並設置android:windowSoftInputMode adjustResize。所以,無論何時打開鍵盤,它都會滾動屏幕來調整視圖,並始終在屏幕上顯示。

希望這個想法適合你。

感謝

+0

+1,你是對的,我做了同樣的事情。 –

+0

「將所有控件放在ScrollView中」是什麼意思? –

0

我在屏幕底部有edittext文件,當我打開softkeyboard時,它隱藏了edittext,因此在佈局上做了修改(使用相對佈局),它在我沒有使用adjustPan的情況下工作。這裏是我的XML。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gen_mainlayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/bg" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <RelativeLayout 
      android:id="@+id/headerlinearLayout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/navigation_bar" > 

      <Button 
       android:id="@+id/chatterBack" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="20dp" 
       android:background="@drawable/navigation_cancel_button" 
       android:textColor="#FFFFFF" > 
      </Button> 

      <TextView 
       android:id="@+id/ittletextView" 
       style="@style/titleText" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:text="Title" > 
      </TextView> 

      <Button 
       android:id="@+id/blockhide" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:layout_marginRight="20dp" 
       android:background="@drawable/navigation_cancel_button" 
       android:padding="5dp" 
       android:text="Block/Hide" 
       android:textColor="#FFFFFF" > 
      </Button> 
     </RelativeLayout> 

     <LinearLayout 
      android:id="@+id/middlelinearLayout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/headerlinearLayout" 
      android:orientation="vertical" > 

     </LinearLayout> 


     <LinearLayout 
      android:id="@+id/footerlinearLayout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:background="@drawable/commnet_post_bg" 
      android:gravity="center" 
      android:paddingLeft="5dp" 
      android:paddingRight="5dp" > 


      <EditText 
       android:id="@+id/sendeditText" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginRight="5dp" 
       android:layout_weight="1" 
       android:background="@drawable/comment_post_text_box" 
       android:imeOptions="actionSend|flagNoEnterAction" 
       android:inputType="text" 
       android:paddingLeft="10dp" 
       android:paddingRight="5dp" 
       android:singleLine="true" > 
      </EditText> 

      <Button 
       android:id="@+id/sendButton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/send_button" 
       android:text="Send" 
       android:textColor="#FFFFFF" > 
      </Button> 
     </LinearLayout> 
    </RelativeLayout> 

</LinearLayout> 
-1

您需要將此行添加到您的活動中以調整屏幕。

 <activity android:name=".TodoEdit" 
     android:windowSoftInputMode="adjustResize"> 
+0

正如我在問題中所述adjustResize不會這樣做。 – superfell

1

把你的EditText滾動型內,然後給物業adjustResize,而不是adjustPan,它會自動調整屏幕及其組件。