2011-06-24 110 views
9

之前寫這個問題我已經通過了如下回答/文章閱讀:安卓:EditText上保持隱藏在鍵盤後面

  1. Android soft keyboard covers edittext field
  2. Android keyboard obscures EditText
  3. http://developer.android.com/resources/articles/on-screen-inputs.html
  4. Soft Keyboard Overlapping with EditText Field

Android軟鍵盤默認設置爲平均值它將保持鍵盤上方的所有可編輯區域。但它不足以支付。當我運行它並按下靠近屏幕底部的編輯文本時,鍵盤出現,編輯文本向上移動但不足以看到正在輸入的內容。我用/試過如下:

  1. 在活動的清單android:windowSoftInputMode="adjustPan"。這沒有什麼區別。我也試過把adjustUnspecifiedadjustResize的值也放在一起。它們都不起作用。

  2. <uses-sdk android:minSdkVersion="3" />在清單文件中。我的應用程序針對sdk 2.1及以上版本。儘管如此,我嘗試了它,但沒有奏效。

  3. 使用ScrollView。也不起作用。

有沒有辦法手動管理當按下特定的edittext時鍵盤做多少「平移」。

下面是我的xml文件。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#ffffff">  

    <ImageView 
    android:id="@+id/header" 
    android:layout_width="320dip" 
    android:layout_height="86dip" 
    android:background="@drawable/header_bg"> 
    </ImageView> 

    <ImageView 
    android:layout_width="320dip" 
    android:layout_height="200dip" 
    android:layout_alignParentBottom="true" 
    android:background="@drawable/bg1_btm"> 
    </ImageView> 

     <TextView android:text="Hostname" 
     android:id="@+id/lbl_hostname" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/header"/> 

     <TextView android:text="(Current)" 
     android:id="@+id/lbl_hostname_current" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/lbl_hostname" 
     android:layout_below="@id/header" /> 

     <EditText android:text="EditText" 
     android:id="@+id/editText_hostname" 
     android:layout_below="@id/lbl_hostname" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:maxLength="25"> 
     </EditText> 

     <TextView android:text="Registration URL" 
     android:id="@+id/lbl_registration" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/editText_hostname" /> 

     <TextView android:text="(Current)" 
     android:id="@+id/lbl_registration_current" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/editText_hostname" 
     android:layout_toRightOf="@id/lbl_registration" /> 

     <TextView android:text="http://" 
     android:id="@+id/lbl_url_prefiz" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/lbl_registration" 
     android:paddingTop="10dip" /> 

     <EditText android:text="EditText" 
     android:id="@+id/editText_registration" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf ="@id/lbl_url_prefiz" 
     android:layout_below="@id/lbl_registration"> 
     </EditText> 

     <TextView android:text="Chat" 
     android:id="@+id/lbl_chat" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/editText_registration"/> 

     <TextView android:text="(Current)" 
     android:id="@+id/lbl_chat_current" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/editText_registration" 
     android:layout_toRightOf="@id/lbl_chat"/> 

     <EditText android:text="EditText" 
     android:id="@+id/editText_chat" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/lbl_chat"> 
     </EditText> 

     <TextView android:text="SSID" 
     android:id="@+id/lbl_ssid" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/editText_chat" /> 

     <TextView android:text="(Current)" 
     android:id="@+id/lbl_ssid_current" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/editText_chat" 
     android:layout_toRightOf="@id/lbl_ssid" 
     /> 

     <EditText android:text="EditText" 
     android:id="@+id/editText_ssid" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/lbl_ssid" 
     android:maxLines="1" 
     android:inputType="text" 
     android:layout_marginBottom="25dip"> 
     </EditText> 

     <Button android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/ButtonSave" 
     android:text="Save" 
     android:layout_below="@id/editText_ssid" 
     android:layout_alignParentLeft="true"> 
     </Button> 

     <Button android:text="Continue" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:id="@+id/ButtonContinue" 
     android:layout_below="@id/editText_ssid" 
     android:layout_alignParentRight="true"> 
     </Button> 

</RelativeLayout> 
+0

答案就在這個帖子: http://stackoverflow.com/questions/4559367/soft-keyboard-overlapping-with-edittext-field – kctang

+0

謝謝。我現在已經完成了一項工作。但稍後會檢查。 – skaneria

+0

任何解決方案? – Atmaram

回答

7

嘗試

android:windowSoftInputMode="adjustResize" 

工作對我很好:)

5

嘗試設置你的所有控件佈局的高度和寬度使用的,而不是使用硬編碼值FILL_PARENT或match_parent ......

如果你使用這個,因爲它也刪除這可能擬推你的應用程序向下...

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); 

希望工程......

+0

謝謝。不再有項目來嘗試這個。但是,如果它適用於其他任何人,不適合接受它作爲答案。謝謝您的幫助。 – skaneria

+0

@skaneria:給這個嘗試...我想它應該工作... –

+0

使它可見但禁用滾動視圖和上部視圖有一些問題與它... – deadfish