初学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"
即可解决。
本文介绍在使用Material Design进行Android应用开发时遇到的问题:RecyclerView遮挡AppBarLayout中的控件。通过为RecyclerView指定特定的布局行为解决了该问题。
1058

被折叠的 条评论
为什么被折叠?



