Las vistas inferiores de los padres se ocultan con la vista de diseño del centro de los padres al abrir el teclado

Estoy trabajando en el diseño donde he alineado un cardview en el centro de la pantalla y en contacto con nosotros button en la parte inferior de la pantalla. Este diseño se ve bien cuando el teclado está cerrado.

Parece como abajo: – Introduzca aquí la descripción de la imagen

Layout.xml

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightSum="2"> <ImageView android:id="@+id/login_image" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@drawable/login_background" /> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/grey_background" /> </LinearLayout> <android.support.v7.widget.CardView android:id="@+id/media_card_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_marginLeft="24dp" android:layout_marginRight="24dp" card_view:cardBackgroundColor="@color/white" card_view:cardElevation="4dp" card_view:cardCornerRadius="5dp" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <ImageView android:id="@+id/logoImageView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@color/grey_background" android:padding="15dp" android:src="@drawable/logo_login" /> <EditText android:id="@+id/usertext" android:layout_width="match_parent" android:layout_height="40dp" android:layout_below="@id/logoImageView" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="20dp" android:background="@drawable/edittext_background" android:hint="User ID" android:maxLength="50" android:padding="10dp" android:singleLine="true" android:textColorHint="@color/hint_text_color" android:textSize="16sp" /> <FrameLayout android:id="@+id/passwordLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/usertext" android:layout_marginTop="8dp" android:orientation="horizontal"> <EditText android:id="@+id/passtext" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:background="@drawable/edittext_background" android:fontFamily="sans-serif" android:hint="@string/password" android:inputType="textPassword" android:maxLength="50" android:padding="10dp" android:singleLine="true" android:textColorHint="@color/hint_text_color" android:textSize="16sp" /> <ImageView android:id="@+id/passwordeye" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:padding="8dp" android:layout_marginRight="25dp" android:src="@drawable/eye_close" /> </FrameLayout> <LinearLayout android:id="@+id/termsLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/passwordLayout" android:layout_marginLeft="15dp" android:layout_marginRight="20dp" android:layout_marginTop="15dp" android:gravity="center" android:orientation="horizontal"> <ImageView android:id="@+id/check_box" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:src="@drawable/checkbox_checked" /> <TextView android:id="@+id/terms_and_cond" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:textColor="@color/black" android:textColorLink="#80000000" android:textSize="13sp" /> </LinearLayout> <View android:id="@+id/lineView" android:layout_width="match_parent" android:layout_height="1dp" android:layout_below="@id/termsLayout" android:layout_marginTop="15dp" android:background="@color/grey_background" /> <LinearLayout android:id="@+id/newuser_login_layout" android:layout_width="match_parent" android:layout_height="50dp" android:background="@color/dark_grey" android:layout_below="@id/lineView" android:orientation="horizontal"> <TextView android:id="@+id/newUserButton" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/translucent_round_button" android:gravity="center" android:text="New User ?" android:textColor="@color/grey_text_color" android:textSize="17sp" /> <TextView android:id="@+id/loginbutton" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/bottom_round_button" android:gravity="center" android:text="Login" android:textColor="@color/white" android:textSize="17sp" /> </LinearLayout> </RelativeLayout> </android.support.v7.widget.CardView> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_gravity="center" android:gravity="center" android:orientation="vertical"> <TextView android:id="@+id/contactus_button" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_centerHorizontal="true" android:layout_marginBottom="15dp" android:background="@drawable/contact_us_selector" android:drawableLeft="@drawable/contact_us_green" android:drawablePadding="5dp" android:gravity="center" android:padding="8dp" android:text="Contact Us" android:textColor="@color/black" /> <TextView android:id="@+id/textviewone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginBottom="10dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:gravity="center" android:textColor="@color/black" android:textColorLink="#80000000" android:textSize="13sp" /> </LinearLayout> </RelativeLayout> </ScrollView> <android.support.design.widget.CoordinatorLayout android:id="@+id/snackbarCoordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.design.widget.CoordinatorLayout> <ProgressBar android:id="@+id/progressBar" style="?android:attr/android:progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:visibility="gone" /> </FrameLayout> 

Pregunta: –

Cuando el teclado se abre entonces nos entra en contacto con el button y el texto que está en la parte inferior de la pantalla ancha ocultó detrás de la disposición central. Quiero que no debe ser ocultar, al abrir la pantalla del teclado debe ser desplazarse y póngase en contacto con nosotros button debe estar en la parte inferior.

Al abrir el teclado se ve como: –

Introduzca aquí la descripción de la imagen

En su scrollview añadir android: isScrollContainer = "false" atributo

 <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:isScrollContainer="false"> </ScrollView> 

Sólo una sola línea que añadir …

Añadir android:windowSoftInputMode="stateHidden|adjustPan" en la actividad requerida de su archivo de manifiesto.

El problema aquí es que tu CardView es android:layout_centerInParent="true" , y tu LinearLayout contiene el material "contact us" es android:layout_alignParentBottom="true" .

Volvería a pensar en su diseño, es un poco complicado, pero tal vez usted puede reemplazar android:layout_alignParentBottom="true" en el LinearLayout con android:layout_below="@+id/media_card_view" .

android:windowSoftInputMode="adjustResize" debería hacer el truco.

"adjustResize" The activity's main window is always resized to make room for the soft keyboard on screen.

https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

Aquí está mi diseño:

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightSum="2"> <ImageView android:id="@+id/login_image" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@android:color/holo_blue_bright"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@android:color/darker_gray"/> </LinearLayout> <android.support.v7.widget.CardView android:id="@+id/media_card_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_marginLeft="24dp" android:layout_marginRight="24dp" card_view:cardBackgroundColor="@android:color/white" card_view:cardCornerRadius="5dp" card_view:cardElevation="4dp" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <ImageView android:id="@+id/logoImageView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@android:color/darker_gray" android:padding="15dp" /> <EditText android:id="@+id/usertext" android:layout_width="match_parent" android:layout_height="40dp" android:layout_below="@id/logoImageView" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="20dp" android:background="@android:drawable/editbox_background" android:hint="User ID" android:maxLength="50" android:padding="10dp" android:singleLine="true" android:textColorHint="@color/colorPrimaryDark" android:textSize="16sp"/> <FrameLayout android:id="@+id/passwordLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/usertext" android:layout_marginTop="8dp" android:orientation="horizontal"> <EditText android:id="@+id/passtext" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:background="@android:drawable/editbox_background" android:fontFamily="sans-serif" android:hint="Password" android:inputType="textPassword" android:maxLength="50" android:padding="10dp" android:singleLine="true" android:textColorHint="@color/colorPrimaryDark" android:textSize="16sp"/> <ImageView android:id="@+id/passwordeye" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:layout_marginRight="25dp" android:padding="8dp" android:src="@android:drawable/ic_menu_edit"/> </FrameLayout> <LinearLayout android:id="@+id/termsLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/passwordLayout" android:layout_marginLeft="15dp" android:layout_marginRight="20dp" android:layout_marginTop="15dp" android:gravity="center" android:orientation="horizontal"> <ImageView android:id="@+id/check_box" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:src="@android:drawable/checkbox_on_background"/> <TextView android:id="@+id/terms_and_cond" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:textColor="@android:color/black" android:textColorLink="#80000000" android:textSize="13sp"/> </LinearLayout> <View android:id="@+id/lineView" android:layout_width="match_parent" android:layout_height="1dp" android:layout_below="@id/termsLayout" android:layout_marginTop="15dp" android:background="@android:color/darker_gray"/> <LinearLayout android:id="@+id/newuser_login_layout" android:layout_width="match_parent" android:layout_height="50dp" android:layout_below="@id/lineView" android:background="@android:color/darker_gray" android:orientation="horizontal"> <TextView android:id="@+id/newUserButton" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="New User ?" android:textColorHint="@android:color/darker_gray" android:textSize="17sp"/> <TextView android:id="@+id/loginbutton" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="Login" android:textColor="@android:color/white" android:textSize="17sp"/> </LinearLayout> </RelativeLayout> </android.support.v7.widget.CardView> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignBottom="@id/media_card_view" android:orientation="vertical" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:gravity="center_horizontal" android:layout_below="@+id/media_card_view"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_centerHorizontal="true" android:layout_marginBottom="15dp" android:drawableLeft="@android:drawable/sym_contact_card" android:drawablePadding="5dp" android:padding="8dp" android:text="Contact Us" android:textColor="@android:color/black" android:layout_gravity="center"/> <TextView android:id="@+id/textviewone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginBottom="10dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:gravity="center_horizontal" android:text="Copyright by piotrek1543 @2016" android:textColor="@android:color/black" android:textColorLink="#80000000" android:textSize="13sp"/> </LinearLayout> </RelativeLayout> </ScrollView> <ProgressBar android:id="@+id/progressBar" style="?android:attr/android:progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:visibility="gone"/> </FrameLayout> 

Así es como se ve antes de abrir el teclado

y después:

En primer lugar, abre tu AndroidManifest y en tu sección de LoginActivity esta línea:

  android:windowSoftInputMode="stateVisible|adjustResize"> 

Después de esto, su manifiesto de Activity debería tener el siguiente aspecto:

  <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateVisible|adjustResize"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> 

A continuación, modifique su LinearLayout con textoneview y textview1 campos como este:

  <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignBottom="@id/media_card_view" android:orientation="vertical" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:gravity="center_horizontal" android:layout_below="@+id/media_card_view"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_centerHorizontal="true" android:layout_marginBottom="15dp" android:drawableLeft="@android:drawable/sym_contact_card" android:drawablePadding="5dp" android:padding="8dp" android:text="Contact Us" android:textColor="@android:color/black" android:layout_gravity="center"/> <TextView android:id="@+id/textviewone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginBottom="10dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:gravity="center_horizontal" android:text="Copyright by piotrek1543 @2016" android:textColor="@android:color/black" android:textColorLink="#80000000" android:textSize="13sp"/> </LinearLayout> 

Espero que ayude

EDIT : Si desea dejar BottomSheetStyle de su linearLayout puede utilizar este código:

  <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignBottom="@id/media_card_view" android:orientation="vertical" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:gravity="center_horizontal|bottom" app:layout_behavior="@string/bottom_sheet_behavior" > <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_centerHorizontal="true" android:layout_marginTop="45dp" android:layout_marginBottom="15dp" android:drawableLeft="@android:drawable/sym_contact_card" android:drawablePadding="5dp" android:padding="8dp" android:text="Contact Us" android:textColor="@android:color/black" android:gravity="center" android:layout_gravity="center"/> <TextView android:id="@+id/textviewone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginBottom="10dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:gravity="center_horizontal" android:text="Copyright by piotrek1543 @2016" android:textColor="@android:color/black" android:textColorLink="#80000000" android:textSize="13sp"/> </LinearLayout> 

Así que parecería:

Pero después de abrir el teclado, verá

Su "Contacto" se CardView detrás de CardView . Si desea que TextView s piense en reducir el tamaño de media_card_view . Para mí es demasiado grande para tener ambas vistas visibles.

Usted apenas agrega poca línea en su código

Archivo de manifiesto:

  <activity android:name=".activities.LoginActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:windowSoftInputMode="stateHidden|adjustResize" /> 

Si usted ha fijado el fondo entonces problema con el desplazamiento después fijado programatically fondo como abajo

  getWindow().setBackgroundDrawableResource(R.drawable.app_bg) ; 

Intento poner android:layout_below="@id/media_card_view" en el LinearLayout que contiene el botón de contacto y la eliminación de android:layout_alignParentBottom="true" de él.

También puedes establecer android:layout_height="wrap_content" en el principal RelativeLayout y tal vez eliminar el CoordinatorLayout si no se utiliza en ese diseño.

Espero eso ayude 😉

Por favor, chequee esto. No estoy seguro de que ayude o no.

 ScrollView view = (ScrollView)findViewById(R.id.scrollView); view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.requestFocusFromTouch(); return false; } }); 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.