Android——可折叠式的标题栏

Android——可折叠式的标题栏,第1张

概述可折叠式标题栏效果图:实现步骤:第一步:依赖包:implementation'com.android.support:design:28.0.0'第二步:定义activity_main.xml文件内容如下:<?xmlversion="1.0"encoding="utf-8"?><android.support.design.widget.CoordinatorLayoutxmlns:an 可折叠式的标题栏

效果图:

实现步骤:

第一步:依赖包:
implementation 'com.androID.support:design:28.0.0'
第二步:定义 activity_main.xml文件 内容如下:
<?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"    xmlns:tools="http://schemas.androID.com/tools"    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:theme="@style/themeOverlay.AppCompat.Dark.Actionbar"        >        <androID.support.design.Widget.CollapsingToolbarLayout            androID:layout_wIDth="match_parent"            androID:layout_height="200dp"            app:contentScrim="?attr/colorPrimary"            androID:background="@mipmap/ic_launcher"            app:layout_scrollFlags="scroll|exitUntilCollapsed">        </androID.support.design.Widget.CollapsingToolbarLayout>    </androID.support.design.Widget.AppbarLayout>    <androID.support.design.Widget.floatingActionbutton        androID:ID="@+ID/my_head"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        app:layout_anchor="@ID/appbar"        app:layout_anchorGravity="bottom|center"        app:elevation="6dp"        androID:clickable="true"        app:borderWIDth="0dp"        androID:backgroundTint="#FFEB3B"        app:ripplecolor="#832B2B2B"        androID:layout_marginBottom="20dp"        androID:layout_marginRight="20dp"        app:pressedTranslationZ="12dp"        />    <androID.support.v4.Widget.nestedScrollVIEw        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"        >        <linearLayout            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:orIEntation="vertical"            >            <TextVIEw                androID:layout_wIDth="match_parent"                androID:layout_height="200dp"                androID:background="#2196F3"                androID:textcolor="#FFFFFF"                androID:textSize="28sp"                androID:gravity="center"                androID:layout_marginBottom="10dp"                />            <TextVIEw                androID:layout_wIDth="match_parent"                androID:layout_height="200dp"                androID:background="#2196F3"                androID:textcolor="#FFFFFF"                androID:textSize="28sp"                androID:gravity="center"                androID:layout_marginBottom="10dp"                />            <TextVIEw                androID:layout_wIDth="match_parent"                androID:layout_height="200dp"                androID:background="#2196F3"                androID:textcolor="#FFFFFF"                androID:textSize="28sp"                androID:gravity="center"                androID:layout_marginBottom="10dp"                />        </linearLayout>    </androID.support.v4.Widget.nestedScrollVIEw></androID.support.design.Widget.CoordinatorLayout>

 

结论:

CollapsingToolbarLayout 是不能独立存在的,它必须只能作为AppbarLayout 的子布局来使用,这里先调整AppbarLayout 的告诉来适应图片。

总结

以上是内存溢出为你收集整理的Android——可折叠式的标题栏全部内容,希望文章能够帮你解决Android——可折叠式的标题栏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1111703.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存