PDA

Ver la Versión Completa : [ SOLUCIONADO ] RecyclerView


Merche300
08/07/17, 21:42:59
Veran, tengo un layout que me vuelve loco:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.ramon.campos.ui.MainActivity"
android:background="@color/primaryDarkColor">

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add"/>

</android.support.design.widget.CoordinatorLayout>


</LinearLayout>El caso es que el fabButton me apareze dentro del recyclerview, cosa que deberia salir al final de la ventana y si a la derecha, y debajo del recyclerview sale el fondo blanco, cosa que poniendo:

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="300dp"/>si me aparece el fabbutton por debajo del recycler pero el fondo inferior es blanco tambien.

¿alguna sugerencia?
gracias

Merche300
09/07/17, 07:39:06
Me falta poner algun archivo para obtener respuesta?

kriogeN
09/07/17, 08:54:50
Estás haciendo una jerarquía de Layouts que no tiene mucho sentido, imagino que lo que buscas es simplemente la animación del FloatingActionButton cuando scrolleas.

¿Por qué metes el CoordinatorLayout dentro de un LinearLayout? El CoordinatorLayout debe ser el contenedor principal. El LinearLayout te sobra.

Y aunque así te debería funcionar, recuerda que el CoordinatorLayout está pensado para usarse con temas sin Action Bar, e implementar un AppBarLayout. Donde el CollapsingToolbarLayout si que es totalmente opcional.

Merche300
09/07/17, 22:19:49
kriogeN, mi intencion era poner el color dark al final de la pantalla, osea, cambiar el blanco que se ve.
Gracias por tu luz:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primaryDarkColor"
tools:context="com.ramon.campos.Campos.MainActivity10">

<android.support.constraint.ConstraintLayout

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

</android.support.constraint.ConstraintLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/ic_add"/>

</android.support.design.widget.CoordinatorLayout>