Android 工具栏在横向中被推回
在我的layout-sw600dp-land文件夹中,此布局文件用于应用程序启动时的主要活动。一旦应用程序启动,就会以编程方式将两个片段添加到相关的框架布局中 此当前布局导致工具栏被推回两个框架布局之后 viewpager片段和右边的片段占据了工具栏的空间,工具栏被推回到它们后面Android 工具栏在横向中被推回,android,android-layout,android-toolbar,Android,Android Layout,Android Toolbar,在我的layout-sw600dp-land文件夹中,此布局文件用于应用程序启动时的主要活动。一旦应用程序启动,就会以编程方式将两个片段添加到相关的框架布局中 此当前布局导致工具栏被推回两个框架布局之后 viewpager片段和右边的片段占据了工具栏的空间,工具栏被推回到它们后面 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.an
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="horizontal" >
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="?attr/ToolBarStyle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
<FrameLayout
android:id="@+id/fragment1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingRight="4dp" />
<FrameLayout
android:id="@+id/fragment2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingRight="4dp" />
</LinearLayout>
<include layout="@layout/nav_drawer_layout" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
双窗格(片段)工具栏布局的适当语法是什么?已解决
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="?attr/ToolBarStyle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
<FrameLayout
android:id="@+id/fragment1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/fragment2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<include layout="@layout/nav_drawer_layout" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
需要注意的一件重要事情是,我想让导航抽屉呈现在所有内容之上,甚至是工具栏,这就是为什么@GabrieleMariotti的评论没有带来我理想的解决方案。使用此布局,可以显示两个片段,也可以在操作栏上显示抽屉布局。抽屉布局适用于两个视图。在您的情况下,您有3个(至少)视图。@GabrieleMariotti您如何建议如何创建我要创建的布局类型?@GabrieleMariotti在两个框架布局的顶部添加边距可使工具栏可见,有更优雅的解决方案吗?将工具栏移到第一个LL中。当我将工具栏移到第一个LL中,并且在DL之前时,会发生这种情况