spannable

How set Spannable object font with custom font

隐身守侯 提交于 2019-11-26 11:42:37
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 Imran Rana This is a late answer but will help others to solve the issue. Use the following code:(I'm using Bangla and Tamil font) TextView txt = (TextView) findViewById(R.id.custom_fonts); txt

Align text around ImageSpan center vertical

与世无争的帅哥 提交于 2019-11-26 10:28:59
问题 I have an ImageSpan inside of a piece of text. What I\'ve noticed is that the surrounding text is always drawn at the bottom of the text line -- to be more precise, the size of the text line grows with the image but the baseline of the text does not shift upward. When the image is noticeably larger than the text size, the effect is rather unsightly. Here is a sample, the outline shows bounds of the TextView : I am trying to have the surrounding text be centered vertically with respect to the

TextView with different textSize

十年热恋 提交于 2019-11-26 05:58:15
问题 Is this possible to set different textSize in one TextView? I know that I can change text style using: TextView textView = (TextView) findViewById(R.id.textView); Spannable span = new SpannableString(textView.getText()); span.setSpan(arg0, 1, 10, arg3); textView.setText(span) I know the range start...end of text I want to change size. But what can I use as arg0 and arg3 ? 回答1: Try span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 回答2: I know very late

select a word on a tap in TextView/EditText

我怕爱的太早我们不能终老 提交于 2019-11-26 04:42:48
问题 How to select a word on a tap in TextView / EditText in android. I have some text in a TextView / EditText and when user taps on a word, I want that word to be selected and after that when I call getSelectedText() like method, it should return me the selected word. Any Help would be appreciated. My goal is to perform some action when user taps on a particular word in TextView / EditText . 回答1: UPDATE: Another better approach is to use BreakIterator : private void init() { String definition =

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