2017-02-23 8 views
0

다음과 같은 문제가 있습니다. 앱의 대부분이 밝은 테마를 사용하는 instagram과 같은 앱 디자인을 얻으려고합니다. 그러나 탐색 모음 및 뒤로 단추 검정과 같은 도구 모음 텍스트 및 아이콘 요소를 채색하는 방법을 찾지 못했습니다.styles.xml이있는 Android 툴바의 색상 관련 항목

다음 style.xml

<resources> 
<!-- Base application theme. --> 
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="colorPrimary">#FAFAFA</item> 
    <item name="colorPrimaryDark">#BDBDBD</item> 
    <item name="colorAccent">#FF4081</item> 
</style> 

<style name="AppTheme" parent="AppTheme.Base"></style> 

<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.ActionBar"> 
    <!-- Used to for the title of the Toolbar --> 
    <item name="android:textColorPrimary">@color/black</item> 
    <!-- Used to for the title of the Toolbar when parent is Theme.AppCompat.Light --> 
    <item name="android:textColorPrimaryInverse">@color/black</item> 
    <!-- Used to color the text of the action menu icons --> 
    <item name="android:textColorSecondary">@color/black</item> 
    <!-- Used to color the overflow menu icon --> 
    <item name="actionMenuTextColor">@color/black</item> 
</style> 
</resources> 

와 도구 모음이 속성 사용 : 당신이 할 수

design with custom toolbar theme

:

android:theme="@style/ToolbarTheme" 

는 다음과 같은 디자인을 생산을 참조하십시오. 탐색 서랍은 흰색이고 탭 제목은 또한 흰색.

나는 또한하지만 잘 작동 것이이 스타일을 시도 명시 적으로이 같은 활동의 도구 모음을 설정하지 않은 경우에만 :

활동 코드 :

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
setSupportActionBar(toolbar); 

Style.xml :

명백한 툴바없이이 스타일을 사용할 때 디자인은 내가 원하는 것처럼 보이지만이 방법으로 툴바를 호출 할 수는 없습니다. Theme.AppCompat.Light를 사용하여 도구 모음을 설정하면 오류가 발생합니다. Theme.AppCompat.Light.NoActionBar

이 작업을 수행하는 방법에 대한 아이디어를 대 Theme.AppCompat.Light :

는 또한 두 스타일의 차이를주의?

답변

0

난 그냥 같이 이제 표준 안드로이드 테마와 함께 갔다 :

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/container" 
    android:theme="@style/ThemeOverlay.AppCompat.Light"> 

    <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="enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     app:titleTextColor="@color/black"/> 
</android.support.design.widget.AppBarLayout> 

이 자신 만의 스타일을 설정하는 것보다 훨씬 쉽다.