2015-05-16 5 views
0

У меня есть вид деятельности с формой. Я помещал все представления в ScrollView, потому что, когда клавиатура открывается, я прокручиваю поля.Keyboard and scrollviews

Когда клавиатура открывается, первое поле переместится вверху ScrollView и становится недоступным.

Это расположение:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:orientation="vertical"> 

    <EditText 
     android:id="@+id/username" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:hint="Username" 
     android:inputType="text|textEmailAddress" 
     android:singleLine="true" /> 

    <EditText 
     android:id="@+id/password" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:hint="Password" 
     android:inputType="textPassword" 
     android:singleLine="true" /> 

    <EditText 
     android:id="@+id/password1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:hint="@string/repeat_password" 
     android:inputType="textPassword" 
     android:singleLine="true" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:orientation="horizontal"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="@string/gender" /> 

     <RadioGroup 
      android:id="@+id/gender" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:paddingLeft="5dp"> 

      <RadioButton 
       android:id="@+id/male" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:checked="true" 
       android:text="M" /> 

      <RadioButton 
       android:id="@+id/female" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="F" /> 
     </RadioGroup> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:orientation="horizontal"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="@string/age" /> 

     <EditText 
      android:id="@+id/age" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:inputType="number" 
      android:paddingLeft="5dp" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:orientation="horizontal"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="@string/education" /> 

     <Spinner 
      android:id="@+id/education" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="5dp" /> 
    </LinearLayout> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:onClick="salva" 
     android:text="@string/save" /> 
</LinearLayout> 

</ScrollView> 

Это определение активности в манифесте:

<activity 
     android:name=".activities.SignUpActivity" 
     android:configChanges="orientation|keyboardHidden|screenSize" 
     android:label="@string/title_activity_sign_up"> 
</activity> 

Это скриншот. Поле имени пользователя недоступно! (Смотреть на скроллинга справа) Screenshot

+0

андроида: windowSoftInputMode = «stateHidden | adjustPan» добавить это в манифесте раздел деятельности –

+1

Таким образом, точка зрения не прокручивать – fran

ответ

0

Я нашел решение. Проблема была в этой строке:

android:layout_gravity="center" 

Я просто удалил ее из файла макета. Явление было правильным.

0

В вашей деятельности манифеста записи добавьте это:

android:windowSoftInputMode="stateVisible|adjustPan".

+0

Таким образом, точка зрения не прокручивать – fran

1

Используйте следующее в вашем App манифеста

android:windowSoftInputMode="stateHidden|adjustPan" 

Для получения более подробной информации вы можете посетить здесь

http://developer.android.com/guide/topics/manifest/activity-element.html

+0

Таким образом, клавиатура покрывает EditText на нижней – fran

+0

@fran ладно , Понимаю . обновите свой xml .http: //stackoverflow.com/questions/14811032/scrollview-not-scrolling-at-all –

+0

Прошу прощения, но не работает – fran