android-fonts

How to programmatically change font settings of Device: font style and font size?

孤街醉人 提交于 2019-12-02 07:19:41
How do we change font type and font size programmatically? I am not referring to changing the font style of a textview or editText. I want to change the global font settings , toggling between font types and font sizes on a button click in my app. I tried checking the Settings.System attributes but I could not find them. Any ideas? You can change system font using below code Settings.System.putFloat(getBaseContext().getContentResolver(), Settings.System.FONT_SCALE, (float) 1.0); and after this give permission in menifest file <uses-permission android:name="android.permission.WRITE_SETTINGS"/>

Text with custom font and bold style

瘦欲@ 提交于 2019-11-30 23:00:23
I am developing an application. I am using custom font. ".ttf" file to customize font of text view. I used the code as: Typeface tfArchitectsDaughter = Typeface.createFromAsset(getAssets(), "fonts/ArchitectsDaughter.ttf"); textview.setTypeface(tfArchitectsDaughter); Now the need is: I want to make the text customize as I done above as well as the style as BOLD in .java file. How to do this please suggest. And what other styles or customization can be done on font please suggest. Use a SpannableString. Also have a look at this tutorial. http://blog.stylingandroid.com/archives/177 . String

How to use custom fonts in DrawerLayout and NavigationView

拥有回忆 提交于 2019-11-30 20:38:22
I want to use Android's DrawerLayout and NavigationView for menus, but I don't know how to have the menu items use a custom font. Does anyone have a successful implementation? use this method passing the base view in your drawer public static void overrideFonts(final Context context, final View v) { Typeface typeface=Typeface.createFromAsset(context.getAssets(), context.getResources().getString(R.string.fontName)); try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); overrideFonts(context, child); } }

Text with custom font and bold style

Deadly 提交于 2019-11-30 17:25:21
问题 I am developing an application. I am using custom font. ".ttf" file to customize font of text view. I used the code as: Typeface tfArchitectsDaughter = Typeface.createFromAsset(getAssets(), "fonts/ArchitectsDaughter.ttf"); textview.setTypeface(tfArchitectsDaughter); Now the need is: I want to make the text customize as I done above as well as the style as BOLD in .java file. How to do this please suggest. And what other styles or customization can be done on font please suggest. 回答1: Use a

How to use custom fonts in DrawerLayout and NavigationView

你说的曾经没有我的故事 提交于 2019-11-30 17:00:35
问题 I want to use Android's DrawerLayout and NavigationView for menus, but I don't know how to have the menu items use a custom font. Does anyone have a successful implementation? 回答1: use this method passing the base view in your drawer public static void overrideFonts(final Context context, final View v) { Typeface typeface=Typeface.createFromAsset(context.getAssets(), context.getResources().getString(R.string.fontName)); try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for

RuntimeException: native typeface cannot be made or memory leak for custom TextView loading font

与世无争的帅哥 提交于 2019-11-30 15:57:44
There's a HUGE problem in my code wherein I am loading a font in my assets\fonts\ folder from a custom TextView class. The first problem is that it crashes on 4.0 devices with the exception Caused by: java.lang.RuntimeException: native typeface cannot be made . I was using the same process here with the method: public class MyTextView extends TextView { public MyTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public MyTextView(Context context, AttributeSet attrs) { super(context, attrs); } public MyTextView(Context context) { super(context); }

Custom ttf fonts are not showing properly in TextView on Android 4.4 KitKat

柔情痞子 提交于 2019-11-30 09:00:22
问题 I have some text which has some bolded parts. Until KitKat this strategy (as mentioned in this post) worked perfectly well My strings resources file: <string name="multi_style_text">NON-BOLD TEXT \n<b>BOLD</b></string> My application code in fragment: txtView.setTypeface(FontUtils.getOstrichRegular(this.getActivity())); ... public static Typeface getOstrichRegular(Context context) { return Typeface.createFromAsset(context.getAssets(), "fonts/ostrich_regular.ttf"); } Currently (in KitKat), the

Android Runtime Exception font asset not found

孤街浪徒 提交于 2019-11-30 03:03:25
问题 Here is my code and screenshot I'm trying to set custom font typeface but Runtime exception occurs font asset not found while font file is in asset folder. Am I missing something ? Typeface font = Typeface.createFromAsset(getAssets(), "font/terminal.ttf"); ((TextView) findViewById(R.id.weatherHeadingTV)).setTypeface(font); 回答1: the folder name has to be 'fonts' not 'font' Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/" + font); 回答2: Your font asset folder is named

Set Indian Rupee symbol on text view

微笑、不失礼 提交于 2019-11-29 20:32:33
I am developing an application. And i need to set the symbol of Indian rupee on text view which is set with the text as amount. Symbol: I am having the font or .TTF file of this in Assets/fonts folder. And i tried to use it as : Typeface typeFace_Rupee = Typeface.createFromAsset(getAssets(),fonts/Rupee_Foradian.ttf"); TextView tvRupee = (TextView) findViewById(R.id.textview_rupee_mlsaa); tvRupee.setTypeface(typeFace_Rupee); // Tried to set symbol on text view as follows. tvRupee.setText("`"); As above setting font i got null pointer error. In word file after choosing font and typing ` we got

How to set custom font for android listview?

好久不见. 提交于 2019-11-29 10:28:31
I am new to android and using custom font for listview.I did not know how to use the typeface in a list view .I also tried with different examples but cant solve my problem .Here is my code public class HomeScreen extends ListActivity { private static final int QUICK_START_INDEX =0; private static final int CUSTOM = 1; private static final int CALL_LIST = 2; private static final int CALENDAR = 3; private static final int TEMPLATES=4; private static final int USER_GUIDE = 5; static final String[] LIST = new String[] { "QuickStart", "Custom", "CallList", "Calendar","Templates","UserGuide"};