Tablayout重叠工具栏

时间:2016-09-18 20:33:27

标签: android xml android-layout toolbar android-coordinatorlayout

我尝试将TablayoutToolbar一起使用,但它会给我如下图所示,并尝试从{{1}移除<item name="android:fitsSystemWindows">true</item>工具栏被android系统状态栏重叠

enter image description here

v21\styles.xml

v21\styles.xml

<resources> <!-- Base application theme. --> <style name="AppTheme" parent="MyMaterialTheme.Base"> <!-- Customize your theme here. --> </style> <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:typeface">serif</item> <item name="android:fitsSystemWindows">true</item> </style> <style name="ToolBarStyle" parent="AppTheme"> <item name="colorControlNormal">@android:color/white</item> </style>

styles.xml

<resources> <!-- Base application theme. --> <style name="AppTheme" parent="MyMaterialTheme.Base"> <!-- Customize your theme here. --> </style> <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:typeface">serif</item> </style> <style name="ToolBarStyle" parent="AppTheme"> <item name="colorControlNormal">@android:color/white</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="PopupTheme" parent="Theme.AppCompat"> <item name="android:background">@color/popColorBg</item> <item name="android:textColor">@android:color/white</item> <item name="android:drawSelectorOnTop">true</item> </style>

activity.xml

根据此Answer,如果我执行此操作并从<android.support.design.widget.CoordinatorLayout 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" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/tools" > <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabGravity="fill" app:tabMaxWidth="0dp" app:tabMode="fixed" /> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <com.melnykov.fab.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="16dp" android:src="@drawable/ic_add_white_24dp" fab:fab_colorNormal="@color/colorPrimaryFab" fab:fab_colorPressed="@color/colorPrimaryDarkFab" fab:fab_colorRipple="@color/colorPrimaryDarkFab" /> 移除android:fitsSystemWindows="true",我的布局将如下所示:

enter image description here

0 个答案:

没有答案