android-typeface

Android : Change Typeface of Edit Text for new text that is entered

爱⌒轻易说出口 提交于 2019-12-14 02:48:54
问题 I want to have different typefaces for different parts of text in the same Edit Text. I have tried doing this to change Typeface : Typeface myFont = Typeface.createFromAsset(getAssets(), "droid-sans.ttf"); myEditText.setTypeface(myFont, Typeface.BOLD); I am using a button to make text BOLD. But this changes Typeface of the entire text that is already present in the EditText ! I want to keep existing text formatting and change Typeface for the text that will be entered after I click "Bold"

NullPointerException when loading typeface from assets in Android Studio

淺唱寂寞╮ 提交于 2019-12-13 04:51:24
问题 I would like to use a custom typeface in my Android app. I followed instructions and created an assets folder in Android studio in which I put verdana.ttf , as shown on the picture: Then I call the following in my MainActivity activity: public class MainActivity extends ActionBarActivity { Typeface mainFont = Typeface.createFromAsset(getAssets(), "verdana.ttf"); The code compiles, but when the activity is launched, I get a NullPointerException on the above line. I suspected the verdana.ttf

how to set Android Typeface from xml

旧时模样 提交于 2019-12-12 09:11:10
问题 Typeface fontRobo = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Black.ttf"); viewTotalValue.setText(total.toString()); 回答1: You could create your own TextView by overriding the TextView like this: public class MyTextView extends TextView { public MyTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setType(context); } public MyTextView(Context context, AttributeSet attrs) { super(context, attrs); setType(context); } public MyTextView

Android Bootstrap by Bearded-Hen Icons Fonts not showing

别来无恙 提交于 2019-12-11 21:46:01
问题 I just downloaded the sample from Android-Bootstrap, But all the fonts Icons are not displaying. I just downloaded the latest version, and still I am having the same problem. (I tried to run the sample project) also same issue. Is anyone have this issue ? or does anyone knows how to came around ? 回答1: fontawesome-webfont.ttf file download and copy to app/src/main/assets. In the OnCreate event of the application, add the following code. TypefaceProvider.registerDefaultIconSets(); 回答2: The

Decoding Urdu Codes in Android

怎甘沉沦 提交于 2019-12-11 11:34:39
问题 I am calling an API and receiving the response in both English and Urdu. The response is stored in a string and the urdu part shows character text like "/u024/". I have been implementing this code set which is giving same result for as before for urdu characters. Kindly if anyone can help me out on this String fontPath = "urdu.ttf"; // text view label TextView txtGhost = (TextView) findViewById(R.id.ghost); // Loading Font Face Typeface tf = Typeface.createFromAsset(getAssets(), fontPath); //

Text view displays Arabic characters as question marks “?????”

放肆的年华 提交于 2019-12-11 05:15:47
问题 I'm working on an android app that displays a textviews with mixed Arabic and English words; the app displays Arabic text that I wrote inside Java classes as question marks ????? here is a screenshot: The Code: if(tCat.equals("StandardT_")){ serviceLine="Operations / خدمات عامة"; } tv.setText(serviceLine); what I have tried: Decoding characters in android and no its not the same question and the answers didn't help. How to support Arabic text in Android? I'm using a new version that supports

How to set a typeface to menu items in overflow menu on toolbar

牧云@^-^@ 提交于 2019-12-10 22:13:34
问题 I want to change the default typeface of the items of the overflow menu and set a custom typeface . I tried adding a Factory to the LayoutInflater and within the onCreateView() method I changed the TextView's typeface . But it didn't work. Here is the code(Inside onCreateOptionsMenu), getLayoutInflater().cloneInContext(this).setFactory(new LayoutInflater.Factory() { @Override public View onCreateView(String name, Context context, AttributeSet attrs) { if (name.contains("com.android.internal

create typeface from font resource id

喜夏-厌秋 提交于 2019-12-09 14:00:34
问题 I have tried using Typeface.createFromAsset(getAssets(),"font/myfont.ttf")); I know font directory should be in assets but in my case, I have an existing font resource directory so I thought asset manager will read from font resource directory but I was wrong. I am creating Typeface to set custom font for collapsingToolbarLayout. I found this answer but it requires me to keep font in assets 回答1: This worked Typeface typeface = ResourcesCompat.getFont(this, R.font.app_font); Found this in the

Text (font) looks faded on older apis

巧了我就是萌 提交于 2019-12-07 03:30:46
问题 I am using a custom typeface, and it displays perfectly on newer android versions(tested on API 17(Asus tab), 18(Dell tab), 19(Nex4) - devices). However, the same typeface looks faded (possibly distorted?) on older versions - API 8(SE X10i), 10(LG P500H). Here's a comparison, in case my explanation doesn't make sense: On nex4: On x10i: I am using a custom typeface with Typeface.BOLD: tvTitle.setTypeface(titleAndBodyFont, Typeface.BOLD); And the body ("Looks *" part): tvBody.setTypeface

Android Notification: add typeface for title and content

纵饮孤独 提交于 2019-12-05 16:02:23
I'm trying to add a Typeface in my NotificationCompat.Builder -> setContentTitle() and setContentText() . I initialized Typeface by Typeface banglaFont = Typeface.createFromAsset(this.getAssets(), "kalpurush.ttf"); in IntentService . To create Notification i used following code. NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this) .setLargeIcon(bitmap) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(userName) .setAutoCancel(true) // .setStyle( // new NotificationCompat.BigTextStyle().bigText(msg)) .setStyle(new NotificationCompat.InboxStyle()) .setVibrate(pattern)