外层CoordinatorLayout 里层AppbarLayout 然后Toolbar <FrameLayout 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:background="@color/primary"> <android.support.v4.widget.DrawerLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/drawer_layout"> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay" app:elevation="0dp"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:minHeight="?attr/actionBarSize" app:layout_scrollFlags="scroll|enterAlways" /> <android.support.design.widget.TabLayout android:id="@+id/layout_tab" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabIndicatorColor="#33000000" app:tabIndicatorHeight="4dp" app:tabPaddingBottom="0dp" app:tabPaddingEnd="0dp" app:tabPaddingStart="0dp" app:tabPaddingTop="0dp" app:tabSelectedTextColor="#fff" app:tabGravity="fill" app:tabTextColor="#fff" /> </android.support.design.widget.AppBarLayout> </android.support.design.widget.CoordinatorLayout> <fragment android:name="com.segmentfault.app.fragment.MineFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="start" /> </android.support.v4.widget.DrawerLayout> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.segmentfault.app.fragment.SplashFragment" android:id="@+id/splash_fragment" /> </FrameLayout> (没有比贴SegmentFault for Android源码更有诚意的了吧?
外层用 CoordinatorLayout,内部嵌套 Toolbar。 具体可以参考这篇博客:http://blog.csdn.net/u010687392/article/details/46852565
外层CoordinatorLayout 里层AppbarLayout 然后Toolbar
(没有比贴
SegmentFault for Android
源码更有诚意的了吧?