我是一名新手Android开发者,正在使用导航抽屉(Navigation Drawer)开发一个练习应用。我希望将主视图设置为一个具有3个选项卡的页面,并且当用户从左到右滑动时,导航抽屉能够显示出来。
这是我的Main.xml代码:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_layout"
tools:context=".ExampleMain" >
<!--
Main Content place holder
-->
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!--
Left Drawer main style
-->
<ListView
style="@style/HighlightColor"
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
/>
</android.support.v4.widget.DrawerLayout>
使用 <Framelayout>
来包含在另一个 xml 文件Main_Content.xml 中定义的实际主视图。
<andriod.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_content_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
我不确定如何将 Viewpager
放置在 Main.xml 的 <FrameLayout>
部分中。请提供一些示例代码或指针。谢谢。