这是我活动中的原始布局:
<?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:fitsSystemWindows="true"
tools:context="com.example.myapp.MyActivity">
<include layout="@layout/content_my_activity"/>
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="snap"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>看上去没问题:

内容布局文件包含一个TableLayout。
由于内容可能很长,我添加了一个NestedScrollView:
<?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:fitsSystemWindows="true"
tools:context="com.example.myapp.MyActivity">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/content_my_activity"/>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="snap"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>现在,布局填充了整个屏幕,标题是AppBar后面的

我该修改什么?
发布于 2015-10-23 19:12:08
嵌套滚动视图被告知在宽度和高度上与父视图匹配,通常ActionBar保留空间并相应地向下推送内容,但是与ToolBar匹配的新AppBarLayout不会这样做。这意味着其他布局需要被告知AppBarLayout的存在。
尝试将其添加到NestedScrollView中
app:layout_behavior="@string/appbar_scrolling_view_behavior"https://stackoverflow.com/questions/33309421
复制相似问题