-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't change Toolbar's font from default. #181
Comments
I noticed that if I commented the default font in the initialization code,
then textAppearance starts to work:
where appearance is
So It seems possible to set fontPath in the app theme to get the Toolbar title works. But I don't really understand why it's so. And for the NavigationView I still have no solution to set font different from default (set in Application or theme). Could you please help me to understand and solve this? |
Hi @Jeevuz I've never tried setting the texAppearance won't work. The Toolbar and Actionbar create the text views programatically, so we have really no idea what style is applied to them, we have to work it out manually. The default font should work. If you want the really easy work around? <Toolbar>
<TextView fontPath="fonts/myFont.ttf" />
</Toolbar> |
Hi Chris, You know what? Your "worth noting" has solved the problem! :) You 100% right, I forgot that starting from support-v22.1 they deprecated the
and added the
toolbar's title font changed. And I changed the font for items in the So, thanks again for your responsiveness! |
Hello Jeevuz, You said in your last comment that you've succeeded to change the font for items in the I can't figure out how I can do that. Can you help me ? Thanks ! |
Hi @LeMimit! Yes, I used the same way as with Toolbar. I set the
Hope it will help you! |
I'm sorry to write in a closed issue, but this really doesn't have any effect for me.. Thanks in advance |
Hi @marbat87! |
What is the navigation view? The new drawer? On Tue, 7 Jul 2015 10:33 marbat87 notifications@github.com wrote:
|
This is because all the new design views don't inflate their children. On Tue, 7 Jul 2015 10:49 Christopher Jenkins chris.mark.jenkins@gmail.com
|
Yes, helper view from design support library. Helps to inflate the drawer from menu xml file. |
This is my code. <android.support.design.widget.NavigationView android:theme="@style/Widget.Design.NavigationView.Risuscito" android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" risuscito:headerLayout="@layout/navdrawer_header" risuscito:menu="@menu/drawer_menu"/> <style name="Widget.Design.NavigationView.Risuscito"> <item name="android:background">@color/navdrawer_background</item> <item name="colorControlHighlight">#12000000</item> <item name="fontPath">fonts/Roboto-Medium.ttf</item> </style> |
I think I solved! I found in support library the item "design_navigation_item.xml" <android.support.design.internal.NavigationMenuItemView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="?attr/listPreferredItemHeightSmall" android:paddingLeft="?attr/listPreferredItemPaddingLeft" android:paddingRight="?attr/listPreferredItemPaddingRight" android:drawablePadding="@dimen/navigation_icon_padding" android:gravity="center_vertical|start" fontPath="fonts/Roboto-Medium.ttf" android:maxLines="1" android:textAppearance="?attr/textAppearanceListItem"/> This works! I think because it overrides the xml included in design support library. Regards, |
I think, your solution works because you set fontPath right on the child view. It's ok, but in case you want to try to workaround without it, try to set your app theme as parent of your style. |
Ups, incidental reopen... sorry :) |
@chrisjenx you said the default should work; I changed my default font, everything except the Toolbar title changed. I also tried @Jeevuz's approach with themes. But that didn't work either. In the application's
Or with the theme option
|
Parent THEME not style. E.g.
|
I tried that too. You said setting default font should work by itself am I wrong? |
If the layout inflater isn't being overwritten by appcompat then yes. Drop On Fri, 31 Jul 2015 12:49 Osman Saral notifications@github.com wrote:
|
@osrl, maybe the problem is that you used the wrong theme for the Toolbar, same as in style you posted. I think default font worked for me by default. My toolbar xml was like this:
|
I use a navigation drawer and change the toolbar title within a main activity (I switch fragments). Different activites have the correct font. But Main activity doesn't.
This is how I change the title. Maybe this is where it goes wrong.
I set a logo on toolbar somewhere in the app. When I comment it out, things go well. How do I tell if the layout inflater is being overwritten by appcompat? |
@osrl Ahh right I know whats going on. The The (really bad) work around for now is to init the
If you do this after the toolbar is created in |
Actually more precisely this:
There is a fix in the works, I have re-worked the Toolbar listener to be a bit more clever. |
Yes @chrisjenx that worked. Thank you. Please let us know when the fix is released, so we can remove the (really bad) workaround :) |
@osrl I updated the |
Did you mean 2.1.1-SNAPSHOT ? |
Yes. |
Sorry couldn't download the snapshot. Do I need to add a repository? Did I miss something? |
In your sample your not using the snapshot. Was that intentional? |
It is same behaviour with or without SNAPSHOT, I tried both. |
OK thanks. On Wed, 16 Mar 2016, 10:50 pickeyboy, notifications@github.com wrote:
|
I found something .. in my main activity I have set for No default action bar by following code in Manifest file. However settings uses the default action bar provided by system. The Calligraphy font is not applied to default actionbar provided in SettingsActivity but it works in MainActivity because main activity's layout xml has got toolbar widget defined and set. Do you think, is that the same reason? |
Yeah, I don't support the action bar, only toolbars. It's too much to On Thu, 17 Mar 2016, 06:40 pickeyboy, notifications@github.com wrote:
|
I have one doubt...i used five fontpath for edittext and textview on xml files...but it wont changed,how to give more than one font path in " CalligraphyConfig"....i used this code but i cant get the ans @OverRide xml file:
|
Try using ttf, otfs are notoriously buggy. You also can't set more than one default typeface. On Thu, 17 Mar 2016, 08:43 shankarimoorthy, notifications@github.com
|
Thankyou for your reply...i will try to slove |
Also if you're using App Compat, you'll need to use the 2.1.1 Snapshot. |
sir i have one doubt..i wish to use more than one ttf files inside the xml page..then how can i use Calligraphy |
@shankarimoorthy you can only define one font in the You can use See the Sample Project, that uses multiple Typefaces. |
Alright, I really didn't want to change font in my whole toolbar, I just wanted Roboto Medium title on Android 4. Calligraphy couldn't apply XpResources2.javaThis class contains some helper code that resolves
XpToolbar.javaUse this class in your XML layouts instead of
I'm sure a clever mind could adapt it to style just subtitle as well. It's even possible that calligraphy inflated such class instead of |
I'm confused why you needed to do that? The title and subtitle styles are On Tue, 19 Apr 2016, 19:38 Eugen Pechanec, notifications@github.com wrote:
|
I basically did it the same way except I styled
My setup was just this:
My toolbar wasn't inflated with the font I specified in my
So I found a way around it. If you have any tips or if I (very much likely) overlooked something I'm all ears. Just a thought: |
Do you have your The Toolbar uses the android:actionBarStyle and Basically Calligraphy resolves the Toolbar styles from the theme Theme -> On Tue, 19 Apr 2016 at 21:49 Eugen Pechanec notifications@github.com
|
Yes, absolutely, then I call
Action bar provided by AppCompat uses
I don't think there's much point to it, all of AppCompat title attributes ( But yes, I tried overriding both toolbar and action bar styles so Using calligraphy 2.2.0 and appcompat 23.3.0. I prepared a tiny project to illustrate what I'm working with. |
Any news on this? I'm having the same problem trying to set |
@consp1racy we look up those attributes manually as those views are never inflated. |
@chrisjenx you mean setting them manually by code or this? <Toolbar>
<TextView fontPath="fonts/myFont.ttf" />
</Toolbar> |
I've just checked I also had to hide the default title. Any of these two options are suitable:
<activity
android:name=".activity.MainActivity"
android:launchMode="singleTop"
android:label=""
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"/> I prefer the second one so that I don't have to add code that is actually part of the view. |
Correct me if I'm wrong, but poking into the source for public Toolbar(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.toolbarStyle);
} setting a style to anything other than that in your theme will have no effect. I'm taking the same approach as @consp1racy and setting my If you point me in the right direction, perhaps I can submit a fix. |
I'm using a workaround, see here: Proguard setup:
Pros: Cons: Usage: How it works: |
Good day sir Chris! How do I set the custom font on the CollapsingToolbarLayout? I am using Android Studio 2.2.3.here is in the activity_main.xml:
and strings.xml here i can see the title set in string:
Please help Sir.. Thank you.. |
hai @Jeevuz i have same problem, im successfully change default font for entire of my app but when i want to change font for my
|
Hi Ramdan, looks just like I do all the time and for me it works. There was
an issue on some older API, maybe 4.3 or something, I don't remember. But
on all others it works. What is your current API?
14 февр. 2017 г. 5:20 пользователь "Ramdan" <notifications@github.com>
написал:
hai @Jeevuz <https://github.com/Jeevuz> i have same problem, im
successfully change default font for entire of my app but when i want to
change font for my toolbar separately its not working. below is what i was
done so far.
`<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/dark_orange"
android:theme="@style/ToolbarTheme">
</android.support.v7.widget.Toolbar>`
<style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<item name="fontPath">@string/titillium_bold</item> </style>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#181 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABjAOcYBpaq-cpcuPo5_LlHpIEl8h6xMks5rcQ-EgaJpZM4E7y6->
.
|
Hello, anybody successfully implemented it with CollapsingToolbarLayout ? <android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
android:theme="@style/ToolbarTheme" <!-- Not working-->
app:expandedTitleTextAppearance="@style/HeaderTitleStyle" <!-- Not working-->
app:collapsedTitleTextAppearance="@style/HeaderTitleStyle" <!-- Not working-->
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout> Styles <style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<item name="fontPath">fonts/Roboto-Medium.ttf</item>
</style>
<style name="HeaderTitleStyle" parent="@android:style/TextAppearance">
<item name="fontPath">fonts/Roboto-Medium.ttf</item>
</style> the attachBaseContext and CalligraphyConfig.initDefault is also set as per main documantation |
thanks for response @Jeevuz, im sory for my newbieness what API do you mean? im tested the app with android kitkat 4.4.2 below is snippet of my build gradle
could you give me some advice please.. |
I asked about the android version. I think that this method not working at
4.4 versions. I don't know why. Try other solutions from Chris, there is
some on top of this thread.
14 февр. 2017 г. 11:25 пользователь "Ramdan" <notifications@github.com>
написал:
… thanks for response @Jeevuz <https://github.com/Jeevuz>, im sory for my
newbieness what API do you mean? im tested the app with android kitkat
4.4.2 below is snippet of my build gradle
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xxx"
minSdkVersion 16
targetSdkVersion 23
versionCode 20
versionName "8.0.9"
}
could you give me some advice please..
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#181 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABjAOQVVQX252U4jTFv4-ht88QMcKA-zks5rcWT9gaJpZM4E7y6->
.
|
We only support the appcompat Toolbar out of the box, you need to add your
own class defs to support otherones.
…On Tue, 14 Feb 2017 at 01:21 Vasili Chyrvon ***@***.***> wrote:
I asked about the android version. I think that this method not working at
4.4 versions. I don't know why. Try other solutions from Chris, there is
some on top of this thread.
14 февр. 2017 г. 11:25 пользователь "Ramdan" ***@***.***>
написал:
> thanks for response @Jeevuz <https://github.com/Jeevuz>, im sory for my
> newbieness what API do you mean? im tested the app with android kitkat
> 4.4.2 below is snippet of my build gradle
>
> compileSdkVersion 23
> buildToolsVersion "23.0.2"
> defaultConfig {
> applicationId "xxx"
> minSdkVersion 16
> targetSdkVersion 23
> versionCode 20
> versionName "8.0.9"
> }
>
> could you give me some advice please..
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <
#181 (comment)
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/ABjAOQVVQX252U4jTFv4-ht88QMcKA-zks5rcWT9gaJpZM4E7y6-
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#181 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHRscz1Ucyg6IKMnhrloyPAA2P8BkGvks5rcXH9gaJpZM4E7y6->
.
|
Hi! I have a problem with changing the Toolbar's title font.
It successfully gets the default font set in Application, but no way to configure it separately.
I tried all solutions, fontPath through textAppearance using Toolbar's setTitleTextAppearance() (and its analog from xml), fontPath in style and use it as toolbar's style, changing the toolbar theme.
Nothing helps...
The same is with new design support library NavigationView. I have no idea how to change the font from default one for items.
Do you have any ideas why it is so?
The text was updated successfully, but these errors were encountered: