J'ai un fragment avec un SwipeRefreshLayout et sera ajouté à l'intérieur d'un FrameLayout dans l'activité lors de l'exécution.La hauteur de SwipeRefreshLayout est toujours 0
Le problème est que la hauteur de SwipeRefreshLayout est toujours 0 quelle que soit la valeur du paramètre height (wrap_content ou match_parent).
Voici mon code fragment:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/expensesLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/expenses_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="@dimen/recycler_view_padding_bottom"
android:paddingTop="@dimen/list_item_margin" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Et voici mon code d'activité:
<?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:fitsSystemWindows="true"
android:layoutDirection="ltr"
tools:context=".expenses.ExpensesActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/dr_nav_header"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleGravity="center_horizontal|bottom"
app:expandedTitleMarginBottom="@dimen/title_margin_bottom"
app:expandedTitleTextAppearance="@style/ExpandedTitle"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout //Inside this frame my fragment will be added
android:id="@+id/contentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_add_expense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/controllers_padding"
android:src="@drawable/ic_add"
app:fabSize="normal"
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
Toutes les suggestions s'il vous plaît?
"SwipeRefreshLayout height est toujours 0" - Comment déterminez-vous exactement? –
Quand je fixerai la hauteur à 200 dp (par exemple) il sera montré! – majdaldeen
Peut-être que c'est "se battre" avec les "ViewGroup" étrangers que vous avez là. Vous n'avez pas besoin de 'NestedScrollView' autour de' FrameLayout', puisque 'RecyclerView's défilent d'eux-mêmes, et le' LinearLayout' autour de 'RecyclerView' n'est pas vraiment nécessaire, sauf si vous mettez quelque chose d'autre dedans . –