1.现状:
在做项目的时候很多时候需要使用侧滑菜单。侧滑菜单项一般都是用Fragment。
一般设计上是在Home page的layout中使用FrameLayout 作为一个container 如:content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.xiaohui.androidhome.tabnavigationbar.MainActivity"
tools:showIn="@layout/app_bar_main">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</RelativeLayout>
用户将FrameLayout 作为Fragment的容器。 在app开始运行的时候,Home的Fragment先填充这个FrameLayout。
当用户切换的时候,用下面语句去替换原有的Fragment。
fragmentManager.beginTransaction().replace(R.id.container, new HomeFragment()).commit();
</pre><pre style="font-family:"DejaVu Sans Mono"; font-size:9pt; background-color:rgb(255,255,255)">2.存在的问题
这种设计对于F