RecyclerView 盖住 AppBarLayout 问题解决

来源:互联网 发布:阿里云免费ssl 编辑:程序博客网 时间:2024/06/07 00:28

初学Android,前几天学到Material Design,非常喜欢这个UI。迫不及待就用MD设计尝试写了个App。
然后在开发过程中遇到了些问题。

<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">    <android.support.design.widget.AppBarLayout        android:id="@+id/appBar"        android:layout_width="match_parent"        android:layout_height="wrap_content">        <android.support.v7.widget.Toolbar            android:id="@+id/toobar"            android:layout_width="match_parent"            android:layout_height="?attr/actionBarSize"            android:background="?attr/colorPrimary"            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>        <!--其他控件-->    </android.support.design.widget.AppBarLayout>    <!--其他控件-->    <android.support.v7.widget.RecyclerView        android:id="@+id/recycler_view"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_marginTop="30dp"/></android.support.design.widget.CoordinatorLayout>

一开始敲上述代码运行时发现RecyclerView盖住了AppBarLayout的除了Toolbar的其他控件。
查书后解决,应给RecyclerView指定一个布局行为,在其tag中添加下述代码。
app:layout_behavior="@string/appbar_scrolling_view_behavior"
即可解决。

阅读全文
0 0