2011-03-06 66 views
4

我正在處理一個具有一些EditText的Activity。當我點擊/觸摸EditText軟鍵盤時出現。但屏幕底部的EditTexts與軟鍵盤重疊。顯示EditText的上半部分,下半部分在鍵盤下方。Android - EditText與Softkeyboard重疊

我設置在AndroidManifest.xml

如何避免它的建議的android:windowSoftInputMode="adjustPan"

回答

4

我想你應該看看this的鏈接。那個概率。看起來與你所擁有的非常相似。

+0

That Link幫助我更多。設置'<使用sdk android:minSdkVersion =「4」/>'而不是3 謝謝..現在工作。 – Shaiful 2011-03-06 10:58:21

+0

提前祝你好運。 – 2011-03-06 11:05:29

0

對我來說,我不想假設鍵盤高度是一定的測量。無論查看您的關注做出onTouchListener然後做到這一點:

setOnTouchListener(new OnTouchListener() { 



     Runnable shifter=new Runnable(){ 
      public void run(){ 
       try { 
        int[] loc = new int[2];     
        //get the location of someview which gets stored in loc array 
        findViewById(R.id.someview).getLocationInWindow(loc); 
        //shift so user can see someview 
        myscrollView.scrollTo(loc[0], loc[1]); 
       } 
       catch (Exception e) { 
        e.printStackTrace(); 
       } 
      }} 
     }; 

     Rect scrollBounds = new Rect(); 
     View divider=findViewById(R.id.someview); 
     myscollView.getHitRect(scrollBounds); 
     if (!divider.getLocalVisibleRect(scrollBounds)) { 
      // the divider view is NOT within the visible scroll window thus we need to scroll a bit. 
      myscollView.postDelayed(shifter, 500); 
     } 



    }); 

//實際上我們做一個可運行的是滾動到要在屏幕上看到一些視圖的新位置。只有當它不在滾動視圖範圍內時(它不在屏幕上),才能執行該可運行。這樣它將scrollview移動到引用的視圖(在我的情況下,'someview'是一個分隔線)。