(工具栏,
标题视图,文本视图,RecyclerVIEw)
当我滚动recyclelervIEw的项目时,我需要标题被折叠.
这样就可以在屏幕上看到“选择项目”和回收器视图.
当工具栏被折叠时,我看到了示例,但是我需要工具栏来始终存在.
我应该使用哪些布局/行为来完成这项工作?
解决方法 你可以通过这样的布局来实现:<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:layout_wIDth="match_parent" androID:layout_height="wrap_content"> <androID.support.design.Widget.CollapsingToolbarLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <!-- header --> <relativeLayout ... app:layout_collapseMode="parallax"> ..... </relativeLayout> <androID.support.v7.Widget.Toolbar androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" app:layout_collapseMode="pin" /> </androID.support.design.Widget.CollapsingToolbarLayout> <!-- IF YOU WANT TO KEEP "Choose Item" always on top of the RecyclerVIEw,put this TextVIEw here <TextVIEw androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_gravity="bottom" androID:text="choose item" /> --> </androID.support.design.Widget.AppbarLayout> <androID.support.v7.Widget.RecyclerVIEw androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" /></androID.support.design.Widget.CoordinatorLayout>
通过拥有app:layout_collapseMode =“pin”属性设置您的工具栏.您可以通过设置app:layout_behavior =“@ string / appbar_scrolling_vIEw_behavior”使RecyclerVIEw正常滚动,这几乎是这样.
NB! “选择项目”的位置TextVIEw取决于您要实现的特定行为:
>您可以将其作为RecyclerVIEw适配器的第一个元素,将其滚动,一旦用户开始滚动RecyclerVIEw;
>你可以将它添加到AppbarLayout中,这样它总是坚持在RecyclerVIEw的顶部,每当你滚动它或不;
您可以在这里阅读更多Android Design Support Library和Design Support Library (III): Coordinator Layout
我希望,它有帮助!
总结以上是内存溢出为你收集整理的android – CoordinatorLayout与RecyclerView和Collapsing标题全部内容,希望文章能够帮你解决android – CoordinatorLayout与RecyclerView和Collapsing标题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)