代码之家  ›  专栏  ›  技术社区  ›  bradley101

将视图寻呼机放置在AppBarLayout下方

  •  4
  • bradley101  · 技术社区  · 8 年前

    我在CollapsableToolbar中的NestedScrollView中有视图寻呼机。但是ViewPager片段的内容隐藏在AppBarLayout后面。 然而,Viewpager是完全可滚动的。

    如何修复此问题?

    <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    
    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="128dp">
    
        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="128dp"
                android:background="@color/colorPrimary">
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="128dp"
                    android:orientation="vertical">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="64dp"
                        android:gravity="center"
                        android:textSize="32dp"
                        android:fontFamily="@font/amaranth"
                        android:text="@string/app_name" />
                    <EditText
                        android:layout_width="match_parent"
                        android:layout_height="59dp"
                        android:background="@drawable/rounded_corners"
                        android:layout_marginRight="14dp"
                        android:hint="Search"
                        android:padding="10dp" />
                </LinearLayout>
            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_scroll_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_anchor="@id/app_bar_layout"
        app:layout_anchorGravity="bottom"
        android:fillViewport="true">
    
        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </android.support.v4.widget.NestedScrollView>
    <android.support.v7.widget.CardView
        app:layout_anchor="@id/nested_scroll_view"
        app:layout_anchorGravity="bottom"
        android:id="@+id/card"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        app:cardElevation="1dp"
        app:cardMaxElevation="3dp">
    
        <android.support.design.widget.TabLayout
    
            android:id="@+id/tablayout"
            style="@style/MyCustomTabTextAppearance"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/whiteColor"
            app:tabGravity="fill"
            app:tabIndicatorColor="@color/tabBackgroundColor"
            app:tabMode="fixed">
    
        </android.support.design.widget.TabLayout>
    
    </android.support.v7.widget.CardView>
    </android.support.design.widget.CoordinatorLayout>
    

    以下是屏幕截图。 我想这一定是appbarlayout的滚动行为。 我是协调布局的新手。

    enter image description here enter image description here

    1 回复  |  直到 8 年前
        1
  •  6
  •   Santanu Sur    7 年前

    添加

    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    

    到nestedscrollView