热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

安卓5.0推出的协调者布局,其实关键的代码都在xml布局中

今天想做一个滑动到屏幕顶端的就停在哪里大图title,搜了一下资料,其实soeasy,直接上代码<?xmlversion1.0encodingut


今天想做一个滑动到屏幕顶端的就停在哪里大图title,搜了一下资料,其实so  easy,直接上代码


xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_match_parent"
    android:layout_match_parent"
    >
    
            android:layout_match_parent"
        android:layout_match_parent">
        
                    android:layout_match_parent"
            android:fitsSystemWindows="true"
            android:layout_wrap_content">

            
                            android:layout_match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                android:layout_100dp">
                                    android:id="@+id/view_pager_head"
                    android:layout_match_parent"
                    android:layout_match_parent">
                

            

            
                              android:background="#ff0000"
                 android:gravity="center"
                 android:text="我是需要固定的头头"
                 android:layout_match_parent"
                 android:layout_50dp" />
        

                    android:id="@+id/rec"
            android:layout_match_parent"
            android:layout_wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    


大家看到这里使用的是RecyclerView,这个android 5.0推出来的心特性,试想一下换成listView 或者Gridview行不行呢?


答案是肯定不行的,listView  和GridView是android5.0之前推出了,和协调者布局一起使用时没有效果的,只能使用RecyclerView啦





推荐阅读
author-avatar
李冰或李冰圆_862
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有