AppBarLayout 不在屏幕顶部
AppBarLayout is not on the top of the screen
我的问题是,AppBarLayout 和工具栏没有出现在屏幕顶部,因此挡住了包含内容的视图。它可以在图像中看到。我确定我只是在这里遗漏了一些东西。
此外,这里是 xml 代码
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_search" />
编辑:我的主题设置为 NoActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
看起来像这样:
在 res/values/styles
中将您的风格设置为 NoActionBar
主题,例如:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
现在,您应该不再使用常规的 ActionBar,而是可以使用工具栏了。
编辑:OP 试图完成的是 CoordinatorLayout
中 AppBar
布局下方的位置包含布局。这是通过将 app:layout_behavior="@string/appbar_scrolling_view_behavior"
添加到包含的布局来实现的。
设置 layout_width 和 layout_height 以匹配包含布局的父级(包含布局内部的布局)。
您应该将主题设置为任何 NoActionBar 主题,例如
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorSecondary</item>
<item name="colorAccent">@color/google_blue</item>
</style>
我的问题是,AppBarLayout 和工具栏没有出现在屏幕顶部,因此挡住了包含内容的视图。它可以在图像中看到。我确定我只是在这里遗漏了一些东西。
此外,这里是 xml 代码
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_search" />
编辑:我的主题设置为 NoActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
看起来像这样:
在 res/values/styles
中将您的风格设置为 NoActionBar
主题,例如:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
现在,您应该不再使用常规的 ActionBar,而是可以使用工具栏了。
编辑:OP 试图完成的是 CoordinatorLayout
中 AppBar
布局下方的位置包含布局。这是通过将 app:layout_behavior="@string/appbar_scrolling_view_behavior"
添加到包含的布局来实现的。
设置 layout_width 和 layout_height 以匹配包含布局的父级(包含布局内部的布局)。
您应该将主题设置为任何 NoActionBar 主题,例如
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorSecondary</item>
<item name="colorAccent">@color/google_blue</item>
</style>