10

Sorunumla ilgili birçok sorunla karşılaştım ancak aradığım davranışı istediğim kimse bulamadım.AppBarLayout + TabLayout + CollapsingToolbarLayout + SwipeToRefresh

İçerdiği parçalar kaydırılabilir olduğunda ve kaydırıldığında (aşağıya doğru), uygulama çubuğunun görünmesini istemediğim sekmeleri ve uygulama çubuğunu içeren bir görünüm çağrısı istiyorum. . Bu fragmanlardan bazıları bir SwipeToRefresh Layout (bazen sorunlara neden olur) içerir. Her zaman yanlış bir şey bırakan birçok yapılandırmayı denedim.

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:wheel="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.m360learning.app.fragment.MainPagerNewsFeed"> 


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

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

      <com.pnikosis.materialishprogress.ProgressWheel 
       android:id="@+id/progress_wheel" 
       android:layout_width="80dp" 
       android:layout_height="80dp" 
       android:layout_centerHorizontal="true" 
       android:layout_centerVertical="true" 
       wheel:matProg_barColor="#5588FF" 
       wheel:matProg_progressIndeterminate="true" /> 

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

     </RelativeLayout> 

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

</FrameLayout> 

ı don:

şimdilik (her zaman gizli)

<?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" 
tools:context=".MainPagerActivity"> 

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

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     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="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginStart="48dp" 
      app:layout_scrollFlags="scroll|enterAlways"> 


      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:tabGravity="fill" 
       app:tabIndicatorHeight="6dp" 
       app:tabMode="fixed" /> 

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


    <android.support.v4.view.ViewPager 
     android:id="@+id/main_pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/app_bar_layout" 
     tools:context=".MainPagerActivity" 

     /> 

</RelativeLayout> 

<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="@android:drawable/ic_menu_edit" /> 

ve benim parçasının (kaydırma bir) birini çöken etkisi yoktur Tam olarak ne yaptığımı bilmiyorum ama bu soruya yazmaya başladığımdan itibaren refreshLayout Listemin çıkmasını engelliyor (yerine yeniliyor) ..

Teşekkürler

------ Düzeltme!

<?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" 
    tools:context=".MainPagerActivity"> 


    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 




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

      <android.support.design.widget.TabLayout 
       android:id="@+id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:tabGravity="fill" 
       app:tabIndicatorHeight="6dp" 
       app:tabMode="fixed" /> 

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


    <android.support.v4.view.ViewPager 
     android:id="@+id/main_pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".MainPagerActivity" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 

     /> 


    <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="@android:drawable/ic_menu_edit" /> 


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

ve parça düzeni: Sir Ellie Zou için

sayesinde, artık bu xml ile çalışır

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:wheel="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.m360learning.app.fragment.MainPagerNewsFeed"> 


    <com.pnikosis.materialishprogress.ProgressWheel 
     android:id="@+id/progress_wheel" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:layout_gravity="center" 
     wheel:matProg_barColor="#5588FF" 
     wheel:matProg_progressIndeterminate="true" /> 

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


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


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


</FrameLayout> 

cevap

11

Eğer paralaks etkisi istemiyorsanız, size ihtiyacım yok CollapsingToolbarLayout kullanmak için.

En önemli yapılandırma:

Toolbar yılında app:layout_scrollFlags="scroll|enterAlways" ayarlayın.

ViewPager'da app:layout_behavior="@string/appbar_scrolling_view_behavior"'u ayarlayın.

Ve düzeni bu gibi görünmelidir:

<android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.AppBarLayout> 

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

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

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

    <android.support.v4.view.ViewPager/> 

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

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

Taşı ProgressWheel senin SwipeRefreshLayout üzerinden SwipeRefreshLayout yenilemek olamaz senin sorunu çözmek için.

+0

Harika! Gönderiyi güncelliyorum, çok teşekkür ederim! –

+0

Oups üzgünüm, fark etmedim ama swipeToRefresh stille kırık, herhangi bir fikir? –

+0

'ProgressWheel' '' SwipeRefreshLayout' –

İlgili konular