typeface

Loading typeface dynamically from url or statically from lib

家住魔仙堡 提交于 2020-01-06 02:40:28
问题 I'm running an Android application and I want to load a font dynamically and use it during runtime. How can I do this? And also how can I include a font in an SDK that I've written, reference the sdk in the app I've written, and use the font included in the SDK? Edit: Thanks for putting a -1 Vote on this, whoever did this, I'll stop sharing knowledge, that's a good way to shut me down. 回答1: Here's how I would do it: (Using an AsyncTask, which is not perfect) If you want something more stable

Custom text font inside a Simplecursoradaptor

自闭症网瘾萝莉.ら 提交于 2020-01-04 02:56:07
问题 I have made an application where i use a SimpleCursoradapter. String[] from = new String[] {"title","notes","image"}; int[] to = new int[] { R.id.esodaTextView, R.id.amountTextView, R.id.imageView1}; esodaAdapter = new SimpleCursorAdapter (this, R.layout.recipe_list_item, null, from, to); As you can see i show the three data at 2 TextViews (esodaTextView + amountTextView) and at one imageView. The question is how can i set a custom font (that is saved at assets folder) to these 2 TextViews

Initialize Typeface in a fragment

别说谁变了你拦得住时间么 提交于 2020-01-03 19:40:53
问题 i have this line : Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Delius-Regular.ttf"); but the getAssets() parameter seems to bring some error, it is underlined with scary red lines, it says The method getAssets() is undefined for the type ProfileFragment ProfileFragment is the name of my class and it extends Fragment. NOTE : The font style is also on the assets folder. 回答1: You cannot get getAssets() from a fragment directly. You have to use getActivity().getAssets() instead

Drawing text on canvas with WINGDING.ttf font is not working on android

偶尔善良 提交于 2020-01-03 00:27:51
问题 When I am drawing Text with custom font(basically icon ex: WINGDING.ttf) using drawText is showing simple text as provided. Steps I followed: 1. Added font file to Assets folder 2. Set paint with the added font 3. drawing text with the paint To draw text I used the corresponding English character canvas.drawText("p",0,1, x, y, myPaint); This displays as p on app 回答1: use this way if you have assets/fonts: private Paint myPaint= new Paint(Paint.ANTI_ALIAS_FLAG); private Typeface mFace; mFace =

Android Help with Changing Button Font Type, How?

断了今生、忘了曾经 提交于 2020-01-01 07:33:21
问题 i would like to change the font that appears on the button text, i have managed to do this with text on the screen, textview, but cannot find any info, or help with applying this to a button. I 'am novice, so providing the code to do so, would be much appreciated. This is what i'am using for the textview, but how do i change the button font? TextView txt = (TextView) findViewById(R.id.custom_font); Typeface font = Typeface.createFromAsset(getAssets(), "1543Humane_jenson_bold.TTF"); txt

Changing all typefaces of an android application [duplicate]

蓝咒 提交于 2019-12-22 08:27:48
问题 This question already has answers here : Is it possible to set a custom font for entire of application? (25 answers) Closed 11 months ago . How can I change the entire typeface of my android application? previously I saw this post on github.The solution work fine only for devices with lower than api 21. For android 5 this method doesn't work even if we add a values-v21 folder with styles.xml separately. This is my values-v21/styles.xml : <resources> <style name="AppBaseTheme" parent="Theme

Set Specifc Font to a TextView independent to device

自闭症网瘾萝莉.ら 提交于 2019-12-21 23:24:04
问题 I want to set a custom font to the textView but the font should be device setting's independent. As i have used the Below Code: TextView tv=(TextView)findViewById(R.id.custom); Typeface face=Typeface.createFromAsset(getAssets(), "fonts/HandmadeTypewriter.ttf"); tv.setTypeface(face); but still the font is the one that is set by the on my samsung galaxy s3. I want to set a custom font that is independent to the device's font settings. I have gone through following links and have tried the

Android text style missing light, medium, thin,

北城以北 提交于 2019-12-20 16:54:11
问题 When setting custom fonts for a textview, I can only choose normal, bold or italic: How can I set the style to be light instead of bold in the following example? <TextViewWithCustomFont ... android:textStyle="bold"/> 回答1: This is font specific. Not all fonts have a light , medium , thin attribute/style, but the default font should. You can use the default light font by using fontFamily: sans-serif-light or for thin, fontFamily: sans-serif-thin . For custom fonts, you would need to include the

android - how to set custom typeface in paint object?

拜拜、爱过 提交于 2019-12-20 04:09:35
问题 I want to use a Paint to draw something and here is my code : Paint mMonthTitlePaint = new Paint(); mMonthTitlePaint.setFakeBoldText(true); mMonthTitlePaint.setAntiAlias(true); mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE); mMonthTitlePaint.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/iran_sans_.ttf")); mMonthTitlePaint.setColor(mDayTextColor); mMonthTitlePaint.setTextAlign(Align.CENTER); mMonthTitlePaint.setStyle(Style.FILL); but it is not working and typeface did not apply

Android 5.0 (API 21) fails to render custom fonts / typefaces

北城余情 提交于 2019-12-20 02:05:54
问题 Android 5.0 seems to have trouble rendering custom fonts. This issue does not occur pre Android 5.0 and it does not occur in Android 5.1 (API 22). Here is an example using a font called "coaster", available here: http://www.dafont.com/coaster.font API 21: API 22: Any explanation for this? 回答1: Google has acknowledged that this was an issue in Android 5.0, and has fixed it in Android 5.1: https://code.google.com/p/android-developer-preview/issues/detail?id=608&thanks=608&ts=1404735239 As for