2013-07-10 2 views
2

Когда я ввожу текст в EditText в своем эмуляторе, экран не перемещается вверх, поэтому я не вижу, что я вводил.Экран не перемещается при вводе текста в EditText Android

Я хотел приложить скриншоты, но у меня пока нет нужной репутации.

Это проблема только в следующем коде.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<EditText 
    android:id="@+id/recQsEditText" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView1" 
    android:layout_alignRight="@+id/textView1" 
    android:layout_below="@+id/textView1" 
    android:layout_marginTop="16dp" 
    android:ems="10" 
    android:maxLines="1" 
    android:padding="5dip" 
    android:scrollbarAlwaysDrawVerticalTrack="true" 
    android:scrollbars="vertical" > 

    <requestFocus /> 
</EditText> 

<EditText 
    android:id="@+id/recAnsEditText" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView2" 
    android:layout_alignRight="@+id/recQsEditText" 
    android:layout_below="@+id/textView2" 
    android:layout_marginTop="18dp" 
    android:ems="10" 
    android:maxLines="1" 
    android:padding="5dip" 
    android:scrollbarAlwaysDrawVerticalTrack="true" 
    android:scrollbars="vertical" /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="49dp" 
    android:text="@string/recoveryInfo" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/recQsEditText" 
    android:layout_below="@+id/recQsEditText" 
    android:layout_marginTop="73dp" 
    android:text="@string/recoveryAnsText" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<Button 
    android:id="@+id/setRecQsBtn" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/recAnsEditText" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="48dp" 
    android:text="@string/saveChangesBtn" /> 

</RelativeLayout> 

Между тем, он отлично работает на другом экране в том же приложении.

Рабочий код -

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<EditText 
    android:id="@+id/addUserIdEditText" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/textView1" 
    android:layout_marginLeft="30dp" 
    android:ems="10" 
    android:maxLines="1" /> 

<EditText 
    android:id="@+id/addTitleEditText" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/TextView01" 
    android:layout_below="@+id/TextView01" 
    android:ems="10" 
    android:maxLines="1" > 

    <requestFocus /> 
</EditText> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/addUserIdEditText" 
    android:layout_below="@+id/addTitleEditText" 
    android:text="@string/userIdInputText" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<TextView 
    android:id="@+id/TextView02" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/addUserIdEditText" 
    android:layout_below="@+id/addUserIdEditText" 
    android:text="@string/passwordInputText" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<TextView 
    android:id="@+id/TextView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView1" 
    android:layout_alignParentTop="true" 
    android:layout_marginTop="26dp" 
    android:text="@string/titleInputText" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<EditText 
    android:id="@+id/addPasswordEditText" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/TextView02" 
    android:layout_alignRight="@+id/addUserIdEditText" 
    android:layout_below="@+id/TextView02" 
    android:ems="10" 
    android:inputType="textPassword" 
    android:maxLines="1" /> 

<TextView 
    android:id="@+id/TextView03" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/addPasswordEditText" 
    android:layout_below="@+id/addPasswordEditText" 
    android:text="@string/loginURLinputText" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<EditText 
    android:id="@+id/addLoginUrlEditText" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/TextView03" 
    android:layout_below="@+id/TextView03" 
    android:ems="10" 
    android:maxLines="1" /> 

<EditText 
    android:id="@+id/addOtherNotesEditText" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView2" 
    android:layout_below="@+id/textView2" 
    android:ems="10" 
    android:maxLines="2" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/addLoginUrlEditText" 
    android:layout_below="@+id/addLoginUrlEditText" 
    android:text="@string/otherNotesInputText" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<Button 
    android:id="@+id/saveButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/addOtherNotesEditText" 
    android:layout_marginTop="36dp" 
    android:layout_toRightOf="@+id/textView2" 
    android:onClick="saveOnClick" 
    android:text="@string/saveBtn" /> 

</RelativeLayout> 

Я изо всех сил, чтобы выяснить, почему это не работает. Пожалуйста помоги!

+0

Какое значение имеет значение окнаSoftInputMode в манифесте вашей активности? – njzk2

+0

Я не установил ни одного windowSoftInputMode в своем манифесте ... и он тоже не получил самогенерации. –

+0

Но он работает для всех экранов в моем приложении, кроме одного ... Вот что меня смущает! –

ответ

1

В файле AndroidManifest,

добавить

android:windowSoftInputMode="adjustPan" 

к классу активности.

пример:

<activity 
     android:name=".YourActivity" 
     android:label="@string/app_name" 
     android:windowSoftInputMode="adjustPan" /> 

Это приведет EditText правильно отрегулировано на мягкую клавиатуру. проверьте другие варианты в нем в соответствии с вашими потребностями.