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これを行う方法上の任意のアイデア:

はまた、2つのスタイルの違いに注意してください?

答えて

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> 

これは、独自のスタイルを設定しようとするよりもはるかに簡単です。

関連する問題