Android设置toolbar高度,android – 在CollapsingToolbarLayout中设置视差图像的初始高度...

我有一个

Android活动,它使用CoordinatorLayout内的CollapsingToolbarLayout来实现滚动/折叠工具栏,其中图像作为背景/横幅.

图像是从互联网上加载的,我事先并不知道它的大小.

我希望工具栏最初是一定高度(160dp),但如果图像大于此值,我希望允许用户进一步向下滚动以显示图像的其余部分.但是,这绝不应该自动发生.初始状态是160dp高度,但用户应该能够向下滚动以进一步增加图像的高度.

我似乎无法找到正确的高度/ minheight组合来实现这一目标.这甚至可能吗?

这是我的布局:

xmlns:app="http://schemas.android.com/apk/res-auto"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"

android:background="@color/toolbar_text">

android:id="@+id/coordinatorLayout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true">

android:id="@+id/appBarLayout"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:fitsSystemWindows="true">

android:id="@+id/collapsing_toolbar"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_scrollFlags="scroll|exitUntilCollapsed"

app:contentScrim="?attr/colorPrimary"

android:fitsSystemWindows="true">

android:id="@+id/imgBanner"

android:layout_width="match_parent"

android:layout_height="160dp"

android:scaleType="centerCrop"

android:fitsSystemWindows="true"

app:layout_collapseMode="parallax"/>

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

app:layout_collapseMode="pin"

app:theme="@style/AppToolbarTheme" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_gravity="fill_vertical"

android:clipToPadding="false"

app:layout_behavior="@string/appbar_scrolling_view_behavior" >

...

横幅图像的高度设置为160dp,它控制工具栏最初的大小,但显然这样我无法将其扩展到160dp以上,因为这是视图的高度.

我尝试将160dp高度设置为CollapsingToolbarLayout或AppBarLayout但没有任何帮助,它总是最大160dp的高度我只能向上滚动(较小的图像)而不是向下,即使图像更大并且ImageView设置为缩放为wrap_content.

这是我想要实现的图纸,如果不清楚的话:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值