AppBarLayout和CollapsingToolbarLayout第二波

2023-10-13 09:50

本文主要是介绍AppBarLayout和CollapsingToolbarLayout第二波,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

效果如图


上面是可折叠的head,下面是viewpage +webview。

布局代码如下

<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"><android.support.design.widget.AppBarLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:background="@color/white"android:fitsSystemWindows="true"><android.support.design.widget.CollapsingToolbarLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:fitsSystemWindows="true"app:contentScrim="@color/colorPrimary"app:layout_scrollFlags="scroll|exitUntilCollapsed"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><com.wbkj.artmss.Weight.WrapContentDraweeViewandroid:id="@+id/iv_head"android:layout_width="match_parent"android:layout_height="wrap_content" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:layout_marginRight="20dp"android:layout_marginTop="-30dp"android:background="@drawable/edit_common_yuanjiao"android:orientation="vertical"><ImageViewandroid:layout_width="match_parent"android:layout_height="5dp"android:background="@color/hdlv" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="15dp"android:paddingRight="5dp"><ImageViewandroid:layout_width="34dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/hd_collect" /><TextViewandroid:id="@+id/tv_title"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="15dp"android:textSize="16sp"android:textStyle="bold" /></RelativeLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/tv_title"android:layout_marginTop="20dp"android:paddingLeft="15dp"android:paddingRight="15dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/feiyong"android:textColor="@color/hdlv" /><TextViewandroid:id="@+id/tv_money"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/hdlv"android:textSize="16sp" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="40dp"android:text="@string/renshu"android:textColor="@color/hdlv" /><TextViewandroid:id="@+id/tv_number"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/hdlv"android:textSize="16sp" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/tv_title"android:layout_marginTop="20dp"android:paddingLeft="15dp"><ImageViewandroid:layout_width="12dp"android:layout_height="12dp"android:background="@mipmap/icon_time" /><TextViewandroid:id="@+id/tv_time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="2dp" /><ImageViewandroid:layout_width="12dp"android:layout_height="12dp"android:layout_marginLeft="40dp"android:background="@mipmap/icon_phone" /><TextViewandroid:id="@+id/tv_phone"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/hdlv" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="15dp"android:orientation="horizontal"android:paddingLeft="15dp"><ImageViewandroid:layout_width="12dp"android:layout_height="14dp"android:background="@mipmap/icon_address" /><TextViewandroid:id="@+id/tv_address"android:layout_width="wrap_content"android:layout_height="wrap_content" /></LinearLayout><ImageViewandroid:layout_width="match_parent"android:layout_height="8dp"android:layout_marginTop="15dp"android:background="@color/qline" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:paddingBottom="15dp"android:paddingLeft="10dp"android:paddingRight="10dp"android:paddingTop="15dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/zhubanfang" /><TextViewandroid:id="@+id/tv_zbf"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/hint" /></LinearLayout><ImageViewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/qline" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:paddingBottom="15dp"android:paddingLeft="10dp"android:paddingRight="10dp"android:paddingTop="15dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/chengbanfang" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:text="为天地立心,为生民立命,为往圣继绝学,为万世开太平。哈哈哈哈,强势装一波。"android:id="@+id/tv_cbf"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="5dp"android:layout_marginRight="25dp"android:ellipsize="end"android:maxLines="1"android:textColor="@color/hint" /><ImageViewandroid:id="@+id/iv_cbf"android:layout_width="20dp"android:layout_height="20dp"android:layout_alignParentRight="true"android:background="@mipmap/down_arrow" /></RelativeLayout></LinearLayout><ImageViewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/qline" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:paddingBottom="15dp"android:paddingLeft="10dp"android:paddingRight="10dp"android:paddingTop="15dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/xiebanfang" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:id="@+id/tv_xbf"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="5dp"android:layout_marginRight="25dp"android:ellipsize="end"android:maxLines="1"android:textColor="@color/hint" /><ImageViewandroid:id="@+id/iv_xbf"android:layout_width="20dp"android:layout_height="20dp"android:layout_alignParentRight="true"android:background="@mipmap/down_arrow" /></RelativeLayout></LinearLayout><ImageViewandroid:layout_width="match_parent"android:layout_height="8dp"android:background="@color/qline" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingBottom="15dp"android:paddingLeft="10dp"android:paddingRight="10dp"android:paddingTop="15dp"><android.support.v7.widget.RecyclerViewandroid:id="@+id/recycler_view"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginRight="30dp"></android.support.v7.widget.RecyclerView><TextViewandroid:id="@+id/tv_pnumber"android:layout_width="40dp"android:layout_height="40dp"android:layout_alignParentRight="true"android:background="@drawable/hd_head_bg"android:gravity="center"android:text="123人"android:textColor="@color/hdlv"android:textSize="10sp" /></RelativeLayout></LinearLayout></LinearLayout><android.support.v7.widget.Toolbarandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="top"android:minHeight="?attr/actionBarSize"app:layout_collapseMode="pin"app:popupTheme="@style/ThemeOverlay.AppCompat.Light"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/iv_back"android:layout_width="20dp"android:layout_height="20dp"android:background="@mipmap/back" /><ImageViewandroid:id="@+id/iv_share"android:layout_width="20dp"android:layout_height="20dp"android:layout_alignParentRight="true"android:layout_marginRight="13dp"android:background="@mipmap/share_hd" /></RelativeLayout></android.support.v7.widget.Toolbar></android.support.design.widget.CollapsingToolbarLayout></android.support.design.widget.AppBarLayout><LinearLayoutandroid:layout_marginBottom="80dp"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:layout_marginRight="20dp"android:background="@color/white"android:orientation="vertical"app:layout_behavior="@string/appbar_scrolling_view_behavior"><android.support.design.widget.TabLayoutandroid:id="@+id/id_tabLayout"android:layout_width="match_parent"android:layout_height="wrap_content"app:layout_behavior="@string/appbar_scrolling_view_behavior"app:tabGravity="fill"app:tabIndicatorColor="@color/hdlv"app:tabMode="fixed"app:tabSelectedTextColor="@color/black"app:tabTextAppearance="@style/TabLayoutmoney"app:tabTextColor="@color/hint" /><ImageViewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/line" /><android.support.v4.view.ViewPagerandroid:id="@+id/viewpager"android:layout_width="match_parent"android:layout_height="match_parent" /></LinearLayout><Buttonandroid:layout_marginLeft="20dp"android:layout_marginRight="20dp"android:layout_gravity="bottom"android:id="@+id/bt_bm"android:layout_width="match_parent"android:layout_height="40dp"android:layout_marginTop="30dp"android:background="@drawable/hd_bm_bg"android:text="@string/wybm"android:textColor="@color/white" /></android.support.design.widget.CoordinatorLayout>
完全就是对Material Design里面的常用布局的各种属性的理解,与搭配。

坑爹的就是内嵌webview需要用NestedScrollView包裹住,才能正确的连续滑动。至于里面水平滑动重叠的recyclerView和可折叠textview可以看我另外两篇文章。

android.support.v4.widget.NestedScrollView
另外感谢我的女神发姐的图片。不懂的可以留下评论问。

这篇关于AppBarLayout和CollapsingToolbarLayout第二波的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/202389

相关文章

2023-2024 学年第二学期小学数学六年级期末质量检测模拟(制作:王胤皓)(90分钟)

word效果预览: 一、我会填 1. 1.\hspace{0.5em} 1. 一个多位数,亿位上是次小的素数,千位上是最小的质数的立方,十万位是 10 10 10 和 15 15 15 的最大公约数,万位是最小的合数,十位上的数既不是质数也不是合数,这个数是 ( \hspace{4em} ),约等于 ( \hspace{1em} ) 万 2. 2.\hspace{0.5em} 2.

读 深入JAVA虚拟机第二版

JAVA虚拟机 一 安全 沙箱安全模型 传统的安全模式中,运行一个软件前你必须信任他,而沙箱安全模型接收任何来源的代码,沙箱限制了此段代码进行可能破坏系统的任何动作 组成JAVA沙箱的基本组件如下: 类装载器体系结构class文件检验器内置于JAVA虚拟机的安全特性安全管理器及JAVA API 类装载器体系结构 他防止恶意代码去干涉善意的代码 命名空间: 在JAVA虚拟机中,在同一个命名

用于搜索的C++类--出自《编程珠玑》第二版的附录E

今天记录的是《编程珠玑》第二版的附录E代码,本人经过完善之后,聊以自娱,记录一下。代码在VS2017上编译通过。 #include <set>#include <random>#include <iostream>class CIntSetSTL{public:CIntSetSTL(int max_elements, int max_values){}size_t size()const

Node.js 核心技术 Stream (第二版)【讲师辅导】-曾亮-专题视频课程

Node.js 核心技术 Stream (第二版)【讲师辅导】—6549人已学习 课程介绍         本课程是 Node.js 核心技术系列课程之一,课程讲解了 stream 流的原理、实现和调用方式,要想对 Node.js 技术有深层次的掌握,就必须对 stream 精通,因为它是数据的血脉! 一切和 I/O 和数据相关的 API 都会用到 stream ,但只是局限在表面

Node.js - MongooseJS 实战 (第二版)【讲师辅导】-曾亮-专题视频课程

Node.js - MongooseJS 实战 (第二版)【讲师辅导】—9090人已学习 课程介绍         【会员免费】链接 http://edu.csdn.net/lecturer/585 右侧办理会员卡。办会员卡可咨询 QQ 1405491181 。 会员可免费学习已发布的全部课程,和在会员有效期内讲师新发布的全部课程 ,承诺每个月至少增加价值500元+ 的新课程。 m

LeetCode 671.二叉树第二小的结点

这个题我们可以用数组辅助完成,然后进行排序后,再用再进行取值,这是我的代码块: /*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* };*/void Preorder_trave(str

IOS Swift 从入门到精通:闭包第二部分,高级闭包

文章目录 当闭包接受参数时使用闭包作为参数当闭包返回值时使用闭包作为参数简写参数名称高级闭包: 具有多个参数的闭包高级闭包:从函数返回闭包高级闭包:捕获值总结 当闭包接受参数时使用闭包作为参数 这是闭包开始变得有点像线路噪声的地方:传递给函数的闭包也可以接受它自己的参数。 我们一直使用() -> Void它来表示“不接受任何参数并且不返回任何内容”,但是您可以继续填充()闭包应

【Rust日报】2021-11-20 最环保编程语言,Rust 仅次于 C 排第二

最环保编程语言,Rust 仅次于 C 排第二 有没有想过计算机的能耗与编程语言的选择之间是否存在相关性?葡萄牙大学一组研究人员着手量化它。2017年的研究论文《Energy Efficiency across Programming Languages》对 27 种知名软件语言的运行时、内存使用和能耗进行了研究,使用以每种语言表达的十种不同的编程问题来监控此类语言的性能。 文件链接,https

2024.06.22【读书笔记】丨生物信息学与功能基因组学(第十七章 人类基因组 第二部分)【AI测试版】

第二部分:人类基因组的主要结论与网络资源 摘要: 第二部分深入总结了人类基因组计划的关键发现,并介绍了用于探索人类基因组的网络资源。这些结论不仅为我们理解人类生物学提供了新的视角,而且揭示了人类基因组的复杂性和动态性。 学习目标: 掌握人类基因组计划的主要科学结论。熟悉人类基因组中基因的数量和复杂性。了解人类基因组中非编码区域的功能和重要性。学习如何利用网络资源进行人类基因组数据的检索和分

算法导论 第二版 8.2 计数排序

根据伪码编写: #include <iostream>#include <ctime>using namespace std;void counting_sort(int *A, int *B, int *C, int k, int n)//B是排序输出,C用来计数{for(int i = 0; i <= k; i++)//初始化CC[i] = 0;for(int j = 0; j <=