【问题标题】:DrawerLayout + app bar +CoordinatorLayout pull to refreshDrawerLayout + 应用栏 +CoordinatorLayout 拉动刷新
【发布时间】:2016-04-28 09:08:50
【问题描述】:

我现在想实施拉动以刷新整页,我可以在 . content_main 有 viewpager 和 recycleview 。

所以我如何才能拉动刷新整页

base.xml

 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:fitsSystemWindows="true">


<include
    layout="@layout/app_bar_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<!-- The navigation drawer -->
<android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"

    android:fitsSystemWindows="true">

app_bar_main.xml

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:expandedTitleGravity="center"
                        app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

     <android.support.v4.view.ViewPager

                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:layout_marginTop="?attr/actionBarSize"

                    app:layout_collapseMode="pin" />

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

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

【问题讨论】:

    标签: android material-design android-coordinatorlayout swiperefreshlayout


    【解决方案1】:

    看看这段代码:

    <android.support.v4.widget.DrawerLayout             
           xmlns:android="http://schemas.android.com/apk/res/android"           
           android:id="@+id/main_drawer_layout"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:background="@color/colorPrimaryDark"
           android:fitsSystemWindows="true">
    
    
                    <android.support.design.widget.CoordinatorLayout
                        android:id="@+id/coordinator"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
    
                        <include layout="@layout/app_bar_main" />
    
                        <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
                            android:id="@+id/swipeContainer"
                            app:layout_behavior="@string/appbar_scrolling_view_behavior"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">
    
    
                            <include layout="@layout/content_main" />
                        </android.support.v4.widget.SwipeRefreshLayout>
    
                    </android.support.design.widget.CoordinatorLayout>
    
                <android.support.design.widget.NavigationView
                 android:id="@+id/navigation"
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
                 android:layout_gravity="start"
                 android:fitsSystemWindows="true">
    
        </android.support.v4.widget.DrawerLayout>
    

    【讨论】:

    • 即使我需要刷新 app_bar_main,因为应用栏有一些卡片 ui
    • 不确定你的意思。您不想像 Google 收件箱那样有这种行为吗?
    • 我想刷新整个页面,包括 CollapsingToolbarLayout,其中包括一些布局,如 textview
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    • 2019-01-28
    • 2015-09-24
    • 2015-08-23
    • 1970-01-01
    相关资源
    最近更新 更多