2012-08-16 45 views
0

我有一個佈局,其中我有一些建議autoComplete編輯文本。 下面的圖片是它的正常行爲,直到鍵盤幻燈片顯示下面的自動完成下拉

enter image description here

鍵盤來後的下拉進入其隱藏我到外地以上:場。如下所示。 enter image description here

即使鍵盤向上滑動,我應該怎樣做下拉下拉。 我想要結果是這樣的。

enter image description here

謝謝...

+0

重複http://stackoverflow.com/questions/11554766/autocompletetextview-suggestion-list-goes-up#comment15928713_11554766 – nandeesh 2012-08-16 15:03:11

回答

0

我通過隱藏佈局上顯示時鍵盤和關注是這個編輯文本解決了這個。一旦鍵盤被滑動,上面的佈局就會再次出現,這會恢復原來的屏幕。 爲了檢測鍵盤slide_in/slide_out我使用了這樣的東西。

final View activityRootView = findViewById(R.id.activityRoot); 
    activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
      new OnGlobalLayoutListener() { 
       @Override 
       public void onGlobalLayout() { 
        int heightDiff = activityRootView.getRootView() 
          .getHeight() - activityRootView.getHeight(); 
        if (heightDiff > 100) { // if more than 100 pixels, its 
              // probably a keyboard... 
         if (searchText.isFocused()) { 
          //keyboard is shown 
         } 
        } else { 
         if (searchText.isFocused()) { 
          //Keyboard is hidden. 
         } 
        } 
       } 
      });