7

새로 고침을 구현하려고하지만 하위보기의 높이를 래핑하지 않는 SwipeRefreshLayout과 관련된 문제가 있습니다. 뷰 미리보기 및 라이브 빌드에서 높이가 0 인 것처럼 보입니다.AppBarLayout의 SwipeRefreshLayout이 내용을 래핑하지 않습니다.

다음과 같은 레이아웃 : 나는 또한 어떤 성공없이 SwipeRefreshLayoutAppBarLayout의 부모를 만들기뿐만 아니라 SwipeRefreshLayout의 내부에 단수 LinearLayout 퍼팅 시도

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:elevation="0dp"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     app:layout_collapseMode="pin"> 

     <android.support.v4.widget.SwipeRefreshLayout 
      android:id="@+id/swipe_refresh_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <include layout="@layout/child_layout" /> 

     </android.support.v4.widget.SwipeRefreshLayout> 
    </android.support.v7.widget.Toolbar> 

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

. 스 와이프 레이아웃의 높이가 0이되지 않도록하는 유일한 방법은 고정적으로 설정하는 것이지만 하위보기의 높이를 기준으로 동적으로 지정하고 싶습니다.

여기에 누락 된 것이 있습니까? SwipeRefreshLayout의 버그가있는 것 같습니다. LinearLayout으로 바꾸면 콘텐츠가 예상대로 작동하기 때문입니다.

+0

클릭 수 상위에 있어야한다 청결을 유지? 큰 소리로 생각하면 .. – Phix

+3

'child_layout'에 대한 코드를 게시 할 수 있습니까? – Kiya

+0

툴바 내부에서 작업하는 이유는 무엇입니까? 분리하지 않는 이유 – Saveen

답변

4

SwipeRefreshLayoutToolbarAppBarLayout 안에 있습니다. AppBarLayout을 다른 레이아웃으로 랩핑하고 SwipeRefreshLayoutAppBarLayout 아래에 넣어야합니다. 다음은 그 예입니다. 하여 SwipeRefreshLayout 높이가 child_layout의 콘텐츠를 배치하는 경우

<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" 
xmlns:tools="http://schemas.android.com/tools" 
android:fitsSystemWindows="true" 
tools:context="com.vsahin.moneycim.View.MainActivity"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="250dp" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark" 
    android:fitsSystemWindows="true" 
    app:expanded="false"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     app:contentScrim="?attr/colorPrimary" 
     android:fitsSystemWindows="true" 
     android:background="@drawable/gradient_background"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:layout_scrollFlags="scroll|enterAlways" /> 

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

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

<android.support.v4.widget.SwipeRefreshLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

</android.support.v4.widget.SwipeRefreshLayout> 

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

원래 게시물에 포함하는 것을 잊었지만 앱 표시 줄 레이아웃 아래쪽 시트가있는 Recycler보기가 있습니다. 문제는 하단 시트를 열었을 때 시차 효과에 대한 앱 막대 레이아웃이 필요하지만 앱 막대 레이아웃을 새로 고침하기 만하면됩니다. –

1

은 다음 child_layout 높이 match_parent 설정해야 논리합 Android Documentation

<android.support.v4.widget.SwipeRefreshLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/swiperefresh" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
     <!--Child View--> 
    <ListView 
     android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

</android.support.v4.widget.SwipeRefreshLayout> 
0
에 나타낸 바와 같이 모두 SwipeRefreshLayoutchild_layout 높이 match_parent 설정해야

은 투명 View이므로 최상의 설정은 match_parent입니다. 다른보기와 충돌하지 않으며 View을 포함하지 않습니다. 또는 내 Layout

<android.support.v4.widget.SwipeRefreshLayout 
      android:id="@+id/swipe_refresh_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:elevation="0dp"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     app:layout_collapseMode="pin"> 

     <include layout="@layout/child_layout" /> 

    </android.support.v7.widget.Toolbar> 

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

SwipeRefreshLayout 다른 레이어를 오버레이하고에 SwipeRefreshLayout보기의`layout_height`을 변경하면`무엇을 match_parent` 일이 발생