2012-10-09 49 views
1

我在ScrollViews中的EditText滾動行爲有問題,通常它會滾動滾動內容,如果鍵盤打開它。但是,如果你動態地在scrollview裏面填充佈局,鍵盤會推高整個屏幕,其他任何人都有過這個問題。 在此先感謝。ScrollView不響應鍵盤

<ScrollView 
    android:id="@+id/scroll_view" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/header_area" > 

     <LinearLayout 
      android:id="@+id/contentHolder" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 
     </LinearLayout> 
</ScrollView> 

此示例工作正常,線性佈局在滾動視圖中滾動,但它顯示滾動甚至鍵盤關閉。我無法使用固定高度。

<ScrollView 
     android:id="@+id/scroll_view" 
     android:layout_width="fill_parent" 
     android:layout_height="100dip" 
     android:layout_below="@+id/header_area" > 

      <LinearLayout 
       android:id="@+id/contentHolder" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" > 
      </LinearLayout> 
    </ScrollView> 

我已經嘗試過下面的xml,它在新項目上按預期工作,但在我的項目中推高窗口。我發現一些其他人有這個問題,我會盡快分享解決方案。

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


    <RelativeLayout 
     android:id="@+id/header_area" 
     android:layout_width="match_parent" 
     android:layout_height="50dip" > 
    </RelativeLayout> 

    <ScrollView 
     android:id="@+id/scroll_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

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

      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
     </LinearLayout> 
    </ScrollView> 

</LinearLayout> 
+0

你在做LinearLayout裏面添加新的視圖哪個父視圖是ScrollView? – Herry

+0

是的,在scrolView中使用linearLayout。將視圖推入@ + id/contentHolder – ymutlu

+0

您在LinearLayout右側有更多的EditText。您可以顯示您的問題的屏幕截圖。 – Herry

回答

2
<application 
    android:icon="@drawable/is_logo_iphone" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > 

問題是「全屏」主題不支持調整大小。使用

android:theme="@android:style/Theme.Black.NoTitleBar" 

解決了這個問題。
感謝您的回答。

0

這是因爲您的滾動視圖可調整大小。嘗試將您的滾動視圖的高度設置爲match_parent。

嘗試在您的滾動視圖中設置android:fillViewport =「true」。

此外,您不會在您的清單的活動標記中添加類似以下內容的東西:android:windowSoftInputMode="adjustResize"這幾乎毀了我們所有的努力。如果您在清單中有以下內容,請將其刪除。

您可能必須配置您的清單。軟鍵盤可能的配置的Here is a list。它可能是您想要使用的android:windowSoftInputMode="adjustPan"

+0

我已經嘗試過每個組合,但這不起作用。謝謝。 – ymutlu

+0

@ymutlu增加了另一種可能的解決方案 – Warpzit

+0

謝謝,試過了,但沒有回覆。我可能會做錯事。試用這個效果很好的空白項目。 – ymutlu