RecyclerView ocupa todo el espacio de la pantalla

Así que estoy teniendo algunos problemas con un RecyclerView en un archivo de diseño

Aquí está:

<android.support.v7.widget.RecyclerView android:id="@+id/chat_listview" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingRight="@dimen/abc_action_bar_default_padding_material" android:paddingLeft="@dimen/abc_action_bar_default_padding_material" /> <LinearLayout android:layout_below="@id/chat_listview" android:layout_width="match_parent" android:layout_height="@dimen/bottom_bar_height" android:orientation="horizontal" > <EditText android:id="@+id/chat_input_edittext" android:layout_weight="7" android:layout_width="0dp" android:layout_height="match_parent" android:inputType="textAutoCorrect" /> <Button android:id="@+id/chat_send_button" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/ic_action_send_now" /> </LinearLayout> 

El RecyclerView es visible y desplazable, pero el LinearLayout y las vistas dentro no son visibles … He intentado bastantes cosas, pero nada ha funcionado hasta ahora.

¿Puede alguno de ustedes por favor señalarme en la dirección correcta?

¡Muchas gracias de antemano!

Cambie la vista raíz a FrameLayout. Establezca la gravedad de LinearLayout en la parte inferior

 <FrameLayout 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"> <android.support.v7.widget.RecyclerView android:id="@+id/chat_listview" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingRight="@dimen/abc_action_bar_default_padding_material" android:paddingLeft="@dimen/abc_action_bar_default_padding_material" /> <LinearLayout android:layout_below="@id/chat_listview" android:layout_width="match_parent" android:layout_height="@dimen/bottom_bar_height" android:layout_gravity="bottom" android:orientation="horizontal"> <EditText android:id="@+id/chat_input_edittext" android:layout_weight="7" android:layout_width="0dp" android:layout_height="match_parent" android:inputType="textAutoCorrect"/> <Button android:id="@+id/chat_send_button" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/ic_action_send_now"/> </LinearLayout> </FrameLayout> 

Alternativamente, puede ajustar el diseño lineal en FrameLayout y establecerlo en align_parentBottom = true si es un diseño relativo o un diseño lineal en su raíz y tiene otras cosas en su vista.

Cuando se dibuja RecyclerView, calcula todo el tamaño restante en la pantalla a sí mismo antes de dibujar los elementos siguientes y no volver a calcular después de que los otros elementos se dibujan, dejándolos fuera de la pantalla.

El truco es dibujar todos los demás elementos primero, y dejar RecyclerView para el final. FrameLayout ya no funciona, así que utilice un diseño relativo y coloque el último RecyclerView en el archivo de diseño XML.

Ejemplo para agregar una barra con botones debajo del RecyclerView:

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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" android:padding="16dp" tools:context=".MainActivity" > <LinearLayout android:id="@+id/pagination_btns" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignParentBottom="true"> //HERE YOU ALIGN THIS ELEMENT TO THE BOTTOM OF THE PARENT <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="@string/previous_btn_label"/> <Space android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="@string/next_btn_label"/> </LinearLayout> <android.support.v7.widget.RecyclerView android:id="@+id/items_recycler_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="vertical" android:layout_above="@id/pagination_btns"/> //HERE YOU ALIGN THE RECYCLERVIEW ABOVE THE PAGINATION BAR </RelativeLayout> 
  • Cómo convertir TextView en ImageView en android
  • ScrollView no está jugando bien con RelativeLayout
  • Android XML redondeado esquinas recortadas
  • Android Reemplazar "..." con elipsis
  • Android: Añadir divisor entre los elementos de RecyclerView
  • ¿Es posible en android definir constantes en XML que varían con la configuración
  • Usar el nombre del paquete en XML
  • ¿Cómo eliminar la barra de acción azul en Android?
  • ¿Cómo lleno un ListView (en Android) con datos XML o JSON?
  • Error en el archivo strings.xml en Android
  • Cómo agregar un hipervínculo a una pantalla de preferencias (PreferenceActivity)
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.