Android: ScrollView no se desplaza con el teclado hacia fuera


Tengo un diseño con algunas vistas, de las cuales una es un EditText. El diseño cabe fácilmente en una página, PERO, cuando el teclado está fuera, el diseño no se desplaza. He aquí un resumen de mi diseño:

<?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"
    android:background="@drawable/background" >

    <ScrollView
        android:id="@+id/ScrollView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >

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

            <CheckBox/>

            <TextView/>

            <LinearLayout>
                <EditText>
                    <requestFocus />
                </EditText>
            </LinearLayout>

            <TextView/>

            <LinearLayout>
                <Spinner/>
            </LinearLayout>

        </LinearLayout>

    </ScrollView>

    <Button
        android:layout_alignParentBottom="true" />

</RelativeLayout>

Y en mi manifiesto he declarado el atributo:

android:windowSoftInputMode="adjustResize|stateHidden"

¿alguien sabe por qué no funciona, y cómo asegurarse de que funciona?

Gracias de antemano!

Author: Xander, 2013-03-11

7 answers

Tuve el mismo problema y revisé mi actividad en el manifiesto, y la razón por la que no estaba funcionando es porque no utilicé esta propiedad:

android:windowSoftInputMode="adjustResize"

Ahora funciona muy bien y no hay necesidad de hacer anclajes adicionales.

 39
Author: Ciprian,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-11 10:10:52

Bien, aparentemente el android:layout_height de ScrollView no debe ser establecido en wrap_content. Lo puse en match_parent y puse el android:layout_above en el botón en la parte inferior de la página.

No me preguntes por qué, pero esto solucionó el problema.

 32
Author: Xander,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-15 19:38:42

Agrega android:windowSoftInputMode="stateHidden|adjustResize" a tu etiqueta en AndroidManifest.archivo xml. Esto hará que la pantalla se cambie de tamaño al espacio de la izquierda después de que se muestre el teclado de software. Por lo tanto, usted será capaz de desplazarse fácilmente.

 10
Author: Rajesh Hegde,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-14 07:26:20

En mi caso, nada de lo anterior funcionó.

Tenía item name="android:windowTranslucentStatus">true</item> en mi tema. Y se arregló estableciendo android:fitsSystemWindows="true" en el diseño padre donde está mi scrollview.

 8
Author: giorgos29cm,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-12 08:49:50

Mi problema era con un HorizontalScrollView. En mi caso tuve que establecer HorizontalScrollView a:

android:layout_width="match_parent"
android:layout_height="match_parent"

Y eliminar:

 android:layout_above="@+id/closeButton"
 android:layout_below="@+id/logo"

En el AndroidManifest.xml la actividad se establece en:

android:windowSoftInputMode=""

Espero que esto ayude a cualquiera que se cruce con este bicho raro.

 0
Author: gtsouk,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-05 10:18:58

Intente establecer ScrollView como su diseño padre. Funciona como un encanto para mí!

 0
Author: Martino Christanto,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-10 04:30:40
<activity 
    android:windowSoftInputMode="adjustResize"
>

Prueba esto En android manifest ..

 -1
Author: Sufi Ammar Sahb,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-22 16:47:05