2014-01-28 47 views
0

我有一個ScrollView與其中的一些小部件,其中一個EditText。當我在EditTextid:message)中寫幾行時,我無法將ScrollView一直滾動到頂部,直到關閉軟鍵盤時,它才卡住。之後,如果我再次進入EditText並寫另外幾行,這種情況就不會再發生了。這隻發生在Android 4.x上,而不是2.3上。 如何防止我的ScrollView卡住?ScrollView當鍵盤打開並在EditText中光標卡住

這裏是我的佈局:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:paddingLeft="8dp" 
     android:paddingRight="8dp" > 

     <EditText 
      android:id="@+id/name" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/ihr_name" 
      android:imeOptions="flagNoExtractUi" 
      android:inputType="textPersonName" 
      android:singleLine="true" > 
     </EditText> 

     <EditText 
      android:id="@+id/email" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" 
      android:hint="@string/ihre_email" 
      android:imeOptions="flagNoExtractUi" 
      android:inputType="textEmailAddress" 
      android:singleLine="true" /> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" > 

      <asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton 
       android:id="@+id/startDate" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:id="@+id/starterror" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:layout_marginRight="16dp" 
       android:background="#00000000" /> 
     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" > 

      <asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton 
       android:id="@+id/endDate" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:id="@+id/enderror" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:layout_marginRight="16dp" 
       android:background="#00000000" /> 
     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" > 

      <asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton 
       android:id="@+id/xy" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:id="@+id/adulterror" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:layout_marginRight="16dp" 
       android:background="#00000000" /> 
     </RelativeLayout> 

     <asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton 
      android:id="@+id/tre" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="4dp" 
      android:layout_marginTop="24dp" 
      android:text="Message: " 
      android:textAppearance="@style/StandardTextBold" 
      android:textColor="@color/myorange" /> 

     <EditText 
      android:id="@+id/message" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" 
      android:hint="@string/ihre_nachricht" 
      android:inputType="textNoSuggestions|textMultiLine" 
      android:text="@string/contact_message" /> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:text="@string/pflichtfelder" 
      android:textAppearance="@style/SmallText" /> 

     <Button 
      android:id="@+id/send" 
      style="@style/ButtonTheme" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:text="Senden" /> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:text="@string/contact_datenschutz" 
      android:textAppearance="@style/SmallText" /> 
    </LinearLayout> 

</ScrollView> 

這裏是卡住佈局的截圖(不太可能有趣):

enter image description here

回答

0

你的輸入選項都設置爲平移(保持視圖我們正在輸入可見)

android:windowSoftInputMode="adjustResize"添加到清單中的活動聲明

相關問題