3 Star 44 Fork 10

Ryan Zhu/OhosExtension

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CollapsingToolbarLayout.md 1.76 KB
一键复制 编辑 原始数据 按行查看 历史

CollapsingToolbarLayout

具体用法与Android中一致。

使用

参考其他CollapsingToolbarLayout教程

<com.ryan.ohos.extension.nested.component.CollapsingToolbarLayout
    ohos:id="$+id:toolBarLayout"
    ohos:height="match_parent"
    ohos:width="match_parent"
    ohos:toolbarId="$+id:toolbar"
    ohos:layout_scrollFlags="scroll|exitUntilCollapsed">
    
    <Image
        ohos:height="match_parent"
        ohos:width="match_parent"
        ohos:image_src="$media:ohos"
        ohos:scale_mode="clip_center"
        ohos:layout_collapseMode="parallax"/>
    
    <com.ryan.ohos.extension.widget.toolbar.Toolbar
        ohos:id="$+id:toolbar"
        ohos:height="$float:toolbarHeight"
        ohos:width="match_parent"
        ohos:title="$string:mainability_description"
        ohos:gravity="center"
        ohos:hideNavigationIcon="true"
        ohos:layout_collapseMode="pin"/>

</com.ryan.ohos.extension.nested.component.CollapsingToolbarLayout>

属性

  • titleEnabled 是否替换Toolbar的title
  • expandedTitleMargin
  • expandedTitleMarginStart
  • expandedTitleMarginEnd
  • expandedTitleMarginTop
  • expandedTitleMarginBottom
  • expandedTitleSize
  • expandedTitleColor
  • collapsedTitleSize
  • collapsedTitleColor
  • scrimVisibleHeightTrigger 背景出现的高度阈值
  • scrimAnimationDuration 背景动画的持续时间
  • contentScrim 背景,当滚动达到一定阈值,将会出现一个背景,此背景位于Toolbar之下,其他元素之上
  • toolbarId

子控件属性

  • layout_collapseMode pin-跟随滚动、parallax-视觉差效果
  • layout_collapseParallaxMultiplier 视觉差效果系数

默认值

Toolbar的默认值可以查看src\main\resources\base\element\collapsing_toolbar.json

未实现功能

  • 多行文本暂未测试
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/thoseyears/ohos-extension.git
git@gitee.com:thoseyears/ohos-extension.git
thoseyears
ohos-extension
OhosExtension
master

搜索帮助

A270a887 8829481 3d7a4017 8829481