【发布时间】:2016-05-15 14:41:49
【问题描述】:
我也在尝试为平板电脑视图显示操作栏(以及 optionsMenu)。但是,它不是针对平板电脑的,而是针对手机的。在平板电脑布局中添加 android.support.v7.widget.Toolbar(下面注释掉)时,它显示了一个带有操作栏的空白屏幕。
平板电脑的布局 布局-sw600dp/activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:divider="?android:attr/dividerHorizontal"
android:orientation="horizontal"
android:theme="@android:style/Theme.Holo.Light"
tools:context="akshit.android.com.popularmovies.MainActivity">
<!--
This layout is a two-pane layout for the Items master/detail flow.
<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" >
-->
<fragment
android:id="@+id/fragment_movie_main"
android:name="akshit.android.com.popularmovies.MainActivityFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
tools:layout="@android:layout/list_content" />
<FrameLayout
android:id="@+id/movie_detail_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
<!-- </android.support.v7.widget.Toolbar> -->
</LinearLayout>
activity_main.xml 的基本布局
<?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="akshit.android.com.popularmovies.MainActivity">
<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" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main"/>
</android.support.design.widget.CoordinatorLayout>
【问题讨论】: