0

SwipeRefreshLayout이있는 조각이 있으며 런타임에 액티비티의 FrameLayout 내부에 추가됩니다.SwipeRefreshLayout 높이는 항상 0입니다.

높이 매개 변수 값이 (wrap_content 또는 match_parent)이면 SwipeRefreshLayout height는 항상 0입니다. 여기

내 조각 코드 : 여기

<?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> 

그리고 내 활동 코드 :

<?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> 

어떤 제안하십시오?

+0

"SwipeRefreshLayout height는 항상 0입니다."- 정확히 어떻게 결정 했습니까? –

+0

높이를 200dp로 고정하면 (예를 들어) 표시됩니다! – majdaldeen

+0

아마도 당신이 가지고있는 관계없는 'ViewGroup'들과 "싸우고 있습니다". 'FrameLayout' 주위에'NestedScrollView'가 필요 없습니다. 왜냐하면'RecyclerView'는 스스로 스크롤하기 때문에,'RecyclerView' 주위의'LinearLayout'은 정말로 필요하지 않습니다. 여러분이 거기에 다른 것을 넣지 않는다면 말입니다. . –

답변

0

문제가 해결되었습니다. NestedScrollView를 제거하고 FrameLayout에 그 동작을 부여했습니다.