【发布时间】:2015-10-24 18:40:02
【问题描述】:
在Design Support Library: Collapsing Toolbar Layout博客文章中有一个很好的视差效果的标题图片:
在a simple test project at GitHub 我试图达到类似的效果 - 但由于某种原因,图像被压扁了:
在activity_main.xml 中,我尝试了scaleType 的所有可能值,但图像仍然失真:
<ImageView
android:id="@+id/header_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/header"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
请问我在这里错过了什么?
更新:
我已尝试按照 Apurva 的建议更改为 match_parent(感谢 +1):
<ImageView
android:id="@+id/header_image_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/header2"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
但这无济于事 - 标题图像被压扁:
【问题讨论】:
-
你应该尝试在 ImageView 中写
layout_height = wrap_content
标签: android parallax android-toolbar android-design-library android-coordinatorlayout