android-fonts

How to set font custom font to Spinner text programmatically?

眉间皱痕 提交于 2019-11-26 06:00:21
问题 I have a ttf font file in my assets folder. I know how to use it for textviews with: Typeface externalFont=Typeface.createFromAsset(getAssets(), \"fonts/HelveticaNeueLTCom-Lt.ttf\"); textview1.setTypeface(externalFont); I have defined look for my spinner text in it\'s own xml file (as usuall in android): <?xml version=\"1.0\" encoding=\"utf-8\"?> <TextView xmlns:android=\"http://schemas.android.com/apk/res/android\" android:id=\"@+android:id/text1\" style=\"?android:attr/spinnerItemStyle\"

How to change the FontSize in an Android WebView?

夙愿已清 提交于 2019-11-26 05:28:17
问题 How can you manually change the font size of a webview? e.g. When the page loads up in the webview the font size is like 24pt. and way too large for my android\'s screen. I\'ve looked into the \"websettings\" but it seems that the two are not related. Thanks 回答1: I finally found it:- WebSettings webSettings = webView.getSettings(); either setTextSize or webSettings.setTextSize(WebSettings.TextSize.SMALLEST); This one works too:- webSettings.setDefaultFontSize(10); 回答2: It seems that nowadays

How set Spannable object font with custom font

纵饮孤独 提交于 2019-11-26 02:30:34
问题 I have Spannable object which I want to set its font by a custom font I have loaded before. Typeface tf = Typeface.createFromAsset(getAssets(), \"fonts/font_Name.ttf\"); Spannable span1 = /*Spannable Item*/; /// I want to set span1 to have tf font face??? /// Here where I want help. EDIT : My problem is that I want to set two different custom fonts for the text view so I am working with the Spannable 回答1: This is a late answer but will help others to solve the issue. Use the following code:(I

Android: Want to set custom fonts for whole application not runtime

吃可爱长大的小学妹 提交于 2019-11-26 00:50:20
问题 Is it possible to set any custom font in every control of the application? And not necessarily runtime ? (i.e. from xml if possible or only once for whole application in JAVA file) I can set the font for one control from this code. public static void setFont(TextView textView) { Typeface tf = Typeface.createFromAsset(textView.getContext() .getAssets(), \"fonts/BPreplay.otf\"); textView.setTypeface(tf); } And the problem with this code is it should be called for every control. And i want to

How to set default font family for entire Android app

爷,独闯天下 提交于 2019-11-25 23:51:15
问题 I\'m using the Roboto light font in my app. To set the font I\'ve to add the android:fontFamily=\"sans-serif-light\" to every view. Is there any way to declare the Roboto font as default font family to entire app? I\'ve tried like this but it didn\'t seem to work. <style name=\"AppBaseTheme\" parent=\"android:Theme.Light\"></style> <style name=\"AppTheme\" parent=\"AppBaseTheme\"> <item name=\"android:fontFamily\">sans-serif-light</item> </style> 回答1: The answer is yes. Global Roboto light

Android - Using Custom Font

江枫思渺然 提交于 2019-11-25 23:03:24
问题 I applied a custom font to a TextView , but it doesn\'t seems to change the typeface. Here is my code: Typeface myTypeface = Typeface.createFromAsset(getAssets(), \"fonts/myFont.ttf\"); TextView myTextView = (TextView)findViewById(R.id.myTextView); myTextView.setTypeface(myTypeface); Can anyone please get me out of this issue? 回答1: On Mobiletuts+ there is very good tutorial on Text formatting for Android. Quick Tip: Customize Android Fonts EDIT: Tested it myself now. Here is the solution. You

Is it possible to set a custom font for entire of application?

筅森魡賤 提交于 2019-11-25 22:59:21
问题 I need to use certain font for my entire application. I have .ttf file for the same. Is it possible to set this as default font, at application start up and then use it elsewhere in the application? When set, how do I use it in my layout XMLs? 回答1: Yes with reflection. This works (based on this answer): (Note: this is a workaround due to lack of support for custom fonts, so if you want to change this situation please do star to up-vote the android issue here). Note: Do not leave "me too"