textview

Android textview html font size tag

不打扰是莪最后的温柔 提交于 2020-02-17 05:38:01
问题 I use <font size ="50"> tag in android textview like this resultTextView.setText(Html.fromHtml("<font size='50' color='#337744'>Text Message</font>")); resultTextView.setText(Html.fromHtml("<font size=\"50\" color='#337744'>Text Message</font>")); but the problem is the color tag works but size tag doesn't work In this blog http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html it is given that font size tag works. What's wrong in my code? 回答1: There is exact

Programmatically scrolling a word into view in a textview

北城以北 提交于 2020-02-10 03:17:48
问题 I have TextView with a large amount of text, the user searches for something and I highlight the matches, however they may be way down the page, is there a way to scroll to the first match? I looked all over google and did not seem to find anything relevant. My Layout : <ScrollView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:requiresFadingEdge="vertical" android:id="@+id/sclView"> <TextView android:layout_width="match_parent" android

Programmatically scrolling a word into view in a textview

大憨熊 提交于 2020-02-10 03:17:09
问题 I have TextView with a large amount of text, the user searches for something and I highlight the matches, however they may be way down the page, is there a way to scroll to the first match? I looked all over google and did not seem to find anything relevant. My Layout : <ScrollView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:requiresFadingEdge="vertical" android:id="@+id/sclView"> <TextView android:layout_width="match_parent" android

How to adjust index in a string after removing some characters?

筅森魡賤 提交于 2020-02-06 07:57:59
问题 I am very new to regex and text manipulation so this might be trivial for many but it is turning out to be quite a nuisance for me. I have a string like so: *text* text text text *text* where the text b/w the * denotes the text that has to be bold So the desired output is text text text text text I am halfway there using the following code val string = "*text* text text text *text*" val pattern = Pattern.compile("\\*") val matcher = pattern.matcher(string) val spannableString =

How to adjust index in a string after removing some characters?

依然范特西╮ 提交于 2020-02-06 07:57:06
问题 I am very new to regex and text manipulation so this might be trivial for many but it is turning out to be quite a nuisance for me. I have a string like so: *text* text text text *text* where the text b/w the * denotes the text that has to be bold So the desired output is text text text text text I am halfway there using the following code val string = "*text* text text text *text*" val pattern = Pattern.compile("\\*") val matcher = pattern.matcher(string) val spannableString =

Change top padding of nine-patch image after stretching

匆匆过客 提交于 2020-02-05 09:37:31
问题 I have TextView with nine-patch background image: The vertical padding is set to fit text into bottom grey rectangle like this: But when the image is stretched vertically, it's top padding saves its absolute value, so text goes above of expected place: How to make TextView increase top padding after vertical stretch and fit text into bottom area which is not stretchable? 来源: https://stackoverflow.com/questions/20177163/change-top-padding-of-nine-patch-image-after-stretching

Two arrays in one TextView in a ListView

烈酒焚心 提交于 2020-02-05 06:20:47
问题 I have a question that I would love to get an answer on. I have two arrays, let's say: String[] name = {"Name Nameson", "Second Name"}; String[] number = {"111 11 111", "222 22 222"}; I want my ListView to have two TextViews into one item.(I tried to illustrate this with a picture). I manage to get f.ex. my name array into the listview with a simple lv.setAdapter(new ArrayAdapter<String>(this, R.layout.single_name, name)); I have my main.xml with my ListView in it, single_name.xml and single

How to set text color for all the TextViews programatically?

ⅰ亾dé卋堺 提交于 2020-02-05 02:55:11
问题 I am creating 8 TextView s dynamically and adding them in my layout. I want to set their text color. So I have declared the color code in my color.xml and I am setting it as: txt1.setTextColor(getResources().getColor(R.color.off_white)); But I have to redundantly do this for all the TextView s individually. Is there a way wherein I can set it globally for all the TextViews. Something similar to what we can do in jQuery for example: $('input[type="text"]').css('color','white'); 回答1: You can

Spannable text is too wide for TextView

谁说胖子不能爱 提交于 2020-02-04 07:34:50
问题 I have a TextView with the font sans-serif-light . To link some words inside, I set a text as a Spannable like this: final Spannable text = new SpannableString(textView.getText()); final Matcher matcher = PATTERN_TAG.matcher(text); while (matcher.find()) { text.setSpan(span, startIndex, endIndex, 0); } textView.setText(text); textView.setMovementMethod(LinkMovementMethod.getInstance()); The Span that I apply sets the word's font to sans-serif-medium like this: public abstract class

Spannable text is too wide for TextView

家住魔仙堡 提交于 2020-02-04 07:31:31
问题 I have a TextView with the font sans-serif-light . To link some words inside, I set a text as a Spannable like this: final Spannable text = new SpannableString(textView.getText()); final Matcher matcher = PATTERN_TAG.matcher(text); while (matcher.find()) { text.setSpan(span, startIndex, endIndex, 0); } textView.setText(text); textView.setMovementMethod(LinkMovementMethod.getInstance()); The Span that I apply sets the word's font to sans-serif-medium like this: public abstract class