kotlin - custom font to alertDialog
up vote
3
down vote
favorite
I must change default font of alertDialog.setMessage and alertDialog.setTitle but I can't use a custom layout, so I have to change it by code in Kotlin.
I tried using typeface, but he doesn't detect the font in res/font/product_sans_bold.ttf
I also used
content.text = Html.fromHtml(resources.getString(R.string.centripetaFormule))
content.typeface = ResourcesCompat.getFont(applicationContext, R.font.product_sans_bold)
alertDialog.setView(content)
and it works, but not as i want.
I have a string
<string name ="centripetaFormule>
Create Typeface Object
Typeface customFont = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf")
Set Typeface to TextView/EditText/Button etc…
TextView textView = (TextView) findViewById(R.id.my_textview);
textView.setTypeface(customFont);
Thanks for the answer, but the problem is that i have an Header and a "normal" text and they must have different fonts, so this method doesn't works well
– Arfmann
Nov 7 at 13:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Android comes with a nice default font but in some cases you might want to use a different font.
Fastest Way to use custom font android
Put your font file in asset folder

Create Typeface Object
Typeface customFont = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf")
Set Typeface to TextView/EditText/Button etc…
TextView textView = (TextView) findViewById(R.id.my_textview);
textView.setTypeface(customFont);
Thanks for the answer, but the problem is that i have an Header and a "normal" text and they must have different fonts, so this method doesn't works well
– Arfmann
Nov 7 at 13:44
add a comment |
up vote
0
down vote
Android comes with a nice default font but in some cases you might want to use a different font.
Fastest Way to use custom font android
Put your font file in asset folder

Create Typeface Object
Typeface customFont = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf")
Set Typeface to TextView/EditText/Button etc…
TextView textView = (TextView) findViewById(R.id.my_textview);
textView.setTypeface(customFont);
Thanks for the answer, but the problem is that i have an Header and a "normal" text and they must have different fonts, so this method doesn't works well
– Arfmann
Nov 7 at 13:44
add a comment |
up vote
0
down vote
up vote
0
down vote
Android comes with a nice default font but in some cases you might want to use a different font.
Fastest Way to use custom font android
Put your font file in asset folder

Create Typeface Object
Typeface customFont = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf")
Set Typeface to TextView/EditText/Button etc…
TextView textView = (TextView) findViewById(R.id.my_textview);
textView.setTypeface(customFont);
Android comes with a nice default font but in some cases you might want to use a different font.
Fastest Way to use custom font android
Put your font file in asset folder

Create Typeface Object
Typeface customFont = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf")
Set Typeface to TextView/EditText/Button etc…
TextView textView = (TextView) findViewById(R.id.my_textview);
textView.setTypeface(customFont);
answered Nov 7 at 13:20
Jose Ribamar
213
213
Thanks for the answer, but the problem is that i have an Header and a "normal" text and they must have different fonts, so this method doesn't works well
– Arfmann
Nov 7 at 13:44
add a comment |
Thanks for the answer, but the problem is that i have an Header and a "normal" text and they must have different fonts, so this method doesn't works well
– Arfmann
Nov 7 at 13:44
Thanks for the answer, but the problem is that i have an Header and a "normal" text and they must have different fonts, so this method doesn't works well
– Arfmann
Nov 7 at 13:44
Thanks for the answer, but the problem is that i have an Header and a "normal" text and they must have different fonts, so this method doesn't works well
– Arfmann
Nov 7 at 13:44
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189861%2fkotlin-custom-font-to-alertdialog%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown