android-fonts

Change font of list fragment on Detail fragment

风格不统一 提交于 2019-12-22 08:24:45
问题 I am trying to implement fragment using android 4.0. I have added the three items in list fragment in my DummyContent.java file static { // Add 3 sample items. addItem(new DummyItem("1", "Videos")); addItem(new DummyItem("2", "Images")); addItem(new DummyItem("3", "Story")); } These Videos,Images,Story are appearing on left side of fragment on click of each it item shows details information on detail fragment in right hand side. I want to change the font of these list views but problem is

Setting Button text font in android

雨燕双飞 提交于 2019-12-22 01:54:03
问题 I have a button created using android widgets. I want to set the font of the button text to Helv Neue 67 Med Cond . How to get this font and set it to the button text in android layout file? 回答1: First you have to put the ttf file in assets folder and then You can use the below code to set Custom font in TextView, same way you can do for Button: TextView txt = (TextView) findViewById(R.id.custom_font); Typeface font = Typeface.createFromAsset(getAssets(), "Helv Neue 67 Med Cond.ttf"); txt

Is it possible to style the android fonts styles with leading and tracking?

╄→гoц情女王★ 提交于 2019-12-20 09:38:00
问题 Is it possible to have the followings in android font styling. Leading (the space vertically between lines of text - name comes from the physical piece of lead that used to be used in mechanical printing process to separate lines of text). Tracking (the horizontal space between each character). If you have any ideas please share with me. 回答1: You can change leading by calling TextView's method setLineSpacing() or changing corresponding XML attributes of TextView in layout ( android

Use Roboto font for earlier devices

时间秒杀一切 提交于 2019-12-20 08:07:38
问题 I would like to use the Roboto font in my Android application and make sure it works for earlier versions of Android that don't have the font installed. I know I can do this by using Typeface.createFromAsset() and then manually setting the font for each of my TextViews/Buttons/Other-Objects. It seems like a big pain to do this for every object I show on the screen though. My question is, is there a better way to do this? Some helper class or a way to set a custom font in a .xml theme file?

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

时光总嘲笑我的痴心妄想 提交于 2019-12-20 05:03:38
问题 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? 回答1: You can change system font using below code Settings.System.putFloat(getBaseContext().getContentResolver(), Settings.System.FONT_SCALE, (float) 1.0); and

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

帅比萌擦擦* 提交于 2019-12-20 05:03:34
问题 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? 回答1: You can change system font using below code Settings.System.putFloat(getBaseContext().getContentResolver(), Settings.System.FONT_SCALE, (float) 1.0); and

Change Toast Font

倖福魔咒の 提交于 2019-12-18 18:46:26
问题 Currently, I'm trying to develop an app. and I don't know how to change the Toast font. . final OnClickListener clickListener = new OnClickListener() { public void onClick(View v) { try { Toast.makeText(nova.this,"Hello", 500000).show(); } catch (Exception e) { Toast.makeText(nova.this,"Exception:" +e, 500000); } } }; I want to change the text "Hello" with custom font I've tried with TypeFace. and Then, I want to set a variable at the place "TextClicked" .. I've tried with a local variable ..

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

若如初见. 提交于 2019-12-18 17:25:43
问题 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,

How to set custom font for android listview?

ⅰ亾dé卋堺 提交于 2019-12-18 05:55:43
问题 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

How to import google fonts in Android Studio?

北城余情 提交于 2019-12-13 20:18:19
问题 I'm a complete beginner to Android Studio, I'd like to know how to import new fonts(more precisely: Roboto and Pacifico font families) 回答1: For setting the font of your step there are some simple steps. 1.select File>New>Folder>Assets Folder 2.click finish 3.right click on assets and create a folder called fonts 4.put your font file in assets > fonts 5.then code to change your font( or create a new theme using that font. ) Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/anyFont.ttf