我的應用程序包含抽屜和任何不同的片段。片段爲活動設置工具欄。爲什麼抽屜圖標不是白色的?我爲任何應用程序使用白色主題。但是,如果從Fragment抽屜圖標調用syncState是黑色的。當我將工具欄移至活動佈局時,一切正常。爲什麼?爲什麼抽屜圖標不是白色的?
對不起,我的英文。
活動佈局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/app_nav_header_main"
app:menu="@menu/main_drawer" />
</android.support.v4.widget.DrawerLayout>
片段佈局:
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/layout_please_wait"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
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:elevation="0dp"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="0dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/AppTheme.AppBarOverlay"
app:tabIndicatorColor="@android:color/white" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/addAds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:src="@drawable/ic_action_new"
app:layout_anchor="@id/pager"
app:layout_anchorGravity="bottom|right|end"
app:layout_behavior="sakh.com.utils.ScrollAwareFABBehavior"
app:useCompatPadding="true" />
</android.support.design.widget.CoordinatorLayout>
<include
layout="@layout/layout_no_internet"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ViewFlipper>
片段代碼:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
((BaseActivity) getActivity()).setSupportActionBar(mToolbar);
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
((BaseActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(true);
((BaseActivity) getActivity()).getDrawerToggle().syncState();
.........
.........
}
試試這個應用程序:itemIconTint = 「#FFFFFF」 –