2017-03-17 5 views
-1

그러나 내 도구 모음/동작 표시 줄을 구현하고 있는데 상태 표시 줄의 색이 갈색으로 바뀌고 진한 파란색 인 dafaults를 표시하려고합니다. 어떻게 바꿀 수 있습니까? 나는 style.xml 테마, 또한 툴바 테마로 놀아 보려고 노력했다. 그러나 나는 그것을 올바르게 할 수 없다. 어떤 도움을 주셔서 감사합니다. 도구 모음의 styles.xml사용자 지정 도구 모음이 상태 표시 줄의 색을 변경합니다.

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

</resources> 

toolbar.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/my_toolbar" 
    android:popupTheme="@style/ThemeOverlay.AppCompat" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="@color/colorPrimary" 
    android:elevation="4dp" 
    android:paddingBottom="5dp" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    tools:context="com.example.com.mytoolbar.MainActivity" /> 

menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 
    <!-- "Mark Favorite", should appear as action button if possible --> 
    <item 
     android:id="@+id/refresh" 
     android:icon="@drawable/ic_refresh_black_48dp" 
     android:title="@string/refresh" 
     app:showAsAction="ifRoom"/> 

    <!-- Settings, should always be in the overflow --> 
    <item android:id="@+id/settings" 
     android:title="@string/settings" 
     app:showAsAction="never"/> 

</menu> 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    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" 
    android:orientation="vertical" 
    tools:context="com.example.com.mytoolbar.MainActivity"> 

    <include layout="@layout/toolbar" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" /> 

</LinearLayout> 
+1

toolbar.xml –

답변

0

사용하여 다음 코드를

당신은 기본 응용 프로그램 테마에서 기본 colorPrimary을 얻을 것이다 android:background="?attr/colorPrimary" 도구 모음을 사용하는 경우
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/my_toolbar" 
    android:popupTheme="@style/ThemeOverlay.AppCompat" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="?attr/colorPrimary"    <!-- Check this line --> 
    android:theme="@style/MyToolbarStyle"     <!-- Custom theme added --> 
    android:elevation="4dp" 
    android:paddingBottom="5dp" 
    tools:context="com.example.com.mytoolbar.MainActivity" /> 

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"을 제거. 변경 텍스트와 오버 플로우 아이콘 색상에

, style.xml 및 도구 모음에 적용이 사용자 정의 테마를 추가하여 :이 도움이

<style name="MyToolbarStyle" parent="Widget.AppCompat.Light.ActionBar"> 
    <item name="android:textColor">@android:color/white</item> 
    <item name="android:textColorPrimary">@android:color/white</item> 
    <item name="android:textColorSecondary">@android:color/white</item> 
</style> 

희망을.

+0

에서 popupTheme을 제거해보세요.하지만 이제는 텍스트 및 오버플로 아이콘이 검은 색으로 표시됩니다. 어떻게 테마 기본값으로 변경할 수 있습니까? 흰색! 도움을 주셔서 감사합니다 – miatech

+0

친절하게 내 업데이트 된 답변을 확인하십시오. – tahsinRupam

+0

그게 전부 .. 모든 백인 테마! 위대한 – miatech