【发布时间】:2016-03-06 04:43:19
【问题描述】:
在主题中声明 .NoActionBar 以及将toolbar 放入布局后,我的toolbar 不显示。我最终得到的正是你在声明没有操作栏时所期望的——没有操作栏。这是布局:
activity_home.xml:
<include
layout="@layout/app_bar_home"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_home"
app:menu="@menu/activity_home_drawer"/>
app_bar_home.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_home"/>
【问题讨论】:
-
您需要提供 xml 的完整结构,而不仅仅是 sn-ps。
activity_home的根视图组类型是什么?是LinearLayout吗?这里最有可能造成麻烦的原因是app_bar_home和nav_view的height属性设置为match_parent,因此其中一个匹配父级并将另一个推到屏幕外。 -
我不太明白。声明 .NoActionBar 后,为什么希望显示工具栏?我总是这样做是为了删除我的工具栏
标签: android android-layout android-activity appbar