我在这里做错了什么。我想使用导航抽屉,然后为内容创建一些片段以显示不同的“页面”。我有导航视图,汉堡菜单等工作得很好。但我似乎无法让我的碎片出现。所以我尝试用文本视图替换我的片段,这样我就可以知道它是否显示出来,但我现在甚至无法将它显示出来。xamarin抽屉带碎片
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" android:id="@+id/includething"/>
<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample Text "/>
<!--<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/includething"/>-->
</RelativeLayout >
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="300dp"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header" />
</android.support.v4.widget.DrawerLayout>
编辑:添加工具栏布局我包括
<?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"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MyTheme">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="?attr/colorPrimary" />
</android.support.design.widget.AppBarLayout>
在一个点上我得到了展现出来的片段,但它是在导航抽屉本身。现在我甚至无法让它出现。我究竟做错了什么?我现在注释掉了片段,只是希望让textview显示在工具栏下方。如果我能做到这一点,我相信我可以让片段工作。
编辑:在尝试板球模式之后,我能够更近一些,但现在看起来工具栏位于主要内容区域的顶部。有没有办法将其向下移动,以便内容从工具栏的底部开始?我将片段的背景变成了黄色,以便更容易在下面的图片中看到。你看不到的是实际上有文本出现在片段中,但被工具栏阻止。
与LinearLayout中...... RelativeLayout的更换RelativeLayout的不具有取向 –
切换到线性布局不会改变任何东西。我仍然看不到文字 –
请显示您包含的工具栏布局,或将其删除。另外,DrawerLayout需要是顶层元素,而不是LinearLayout –