【发布时间】:2016-02-20 18:52:11
【问题描述】:
我有一个协调器布局,它由 appbarlayout 和 nestedscrollview 组成。问题是当我打开活动时,nestedscrollview 的某些部分默认隐藏在展开的操作栏后面(图像中显示的差异)。
XML 文件:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/my_appbar_container"
android:layout_width="match_parent"
android:layout_height="250dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/ivToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:alpha="0.6"
app:layout_collapseParallaxMultiplier="0.7" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_collapseMode="pin"
android:alpha="1.0"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<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="match_parent"
android:orientation="vertical">
......
.......
我无法弄清楚这里的问题是什么,也无法在网上找到任何地方。也许这是一个错误。请检查。
【问题讨论】:
-
为什么要在 NestedScrollView 中设置 app_behavior_overlapTop="-100dp"?
-
啊!我实际上只是想看看会发生什么。在没有它的情况下也面临着这个问题。立即删除。
-
似乎无法使用该布局文件重现此内容。
-
@AndrewSeymour :我收到此错误。也许是设备特定的错误?你用的是什么设备?
-
我不知道发生了什么。看起来,如果我向滚动视图添加一些额外的高度,它会正确显示。现在,在这里添加高度意味着我已经尝试过 - 添加一个随机卡片视图或增加任何一个卡片视图的高度。不知道是什么原因。