Issue
I am trying to change the title color and size of the toolbar but nothing happens. I search everywhere and nothing seems to work. I am using minsdk 19 api. Here is my code:
**activity.main.xml**
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
**style.xml**
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
<!--<item name="colorAccent">@color/primaryLightColor</item>-->
<item name="android:textColor">@color/primaryTextColor</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="actionBarStyle">@style/MyTitleTextStyle</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="MyTitleTextStyle" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textColor">@color/primaryColor</item>
</style>
</resources>
Solution
It's well explained here. Add this to your Toolbar:
app:titleTextAppearance="@style/Toolbar.TitleText"
And create a style for it:
<style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textColor">#FFFFFF</item>
</style>
Answered By - Suleyman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.