spannable

Android Development: How To Replace Part of an EditText with a Spannable

旧城冷巷雨未停 提交于 2019-11-27 06:13:10
问题 I'm trying to replace part of an Editable returned from getText() with a span. I've tried getText().replace() but that's only for CharSequences . The reason I'm trying to do this is so I can highlight sections of an EditText one after another (after a small delay), instead of going through and highlighting the whole EditText (which can be slow with big files). Does anyone have a clue about how I'd go about doing this? 回答1: This minimal size example makes the word 'first' large: public class

SpannableString: Is it possible to apply two or more RelativeSizeSpans?

社会主义新天地 提交于 2019-11-27 05:11:33
问题 I am trying to construct a SpannableString such that it looks like this: Two characters (m, s) should be smaller than the rest. I have tried to hold all the text in one SpannableString, and I also tried to concatenate two SpannableStrings via a SpannableStringBuilder. The code for one Spannable looks like this: spannable.setSpan(new RelativeSizeSpan(0.75f), spannable.length() - 1, spannable.length(), 0); However, only one formatting is applied - when using the SpannableStringBuilder, only the

Button setText with Spannable doesn't work for Android 5.0 Lollipop

守給你的承諾、 提交于 2019-11-27 04:45:35
问题 I have a simple Button : <Button android:id="@+id/test" android:textColor="@color/white" android:layout_width="wrap_content" android:layout_height="wrap_content" /> and try to change text property by: SpannableString span = new SpannableString(text); span.setSpan(new AbsoluteSizeSpan(8, true), 5, 10, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); testButton.setText(span); It works on Android 4.3 but doesn't on 5.0. The interesting thing is when I change implementation from Button to TextView it works

Align text around ImageSpan center vertical

本小妞迷上赌 提交于 2019-11-27 03:23:57
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 image being displayed. Here is the same sample with blue text showing the desired location: Here are the

How to click or tap on a TextView text on different words?

血红的双手。 提交于 2019-11-27 00:40:30
How to move to another view by click on text view with two different words. this is the string i am using. By clicking Sign Up, you are indicating that you have read and agree to the Term of Use and Privacy Policy. i want to make these two words (Term of Use, Privacy Policy) in different color and clickable.. i know ho to make color for a particular word. i want to make it clickable . I finally figured it out how to have multiple clickable parts in a TextView. It is important that they all have their own ClickableSpan! That is where I went wrong the first time testing it. If they have the same

Android SpannableString set background behind part of text

不想你离开。 提交于 2019-11-27 00:31:01
I would like to create something similar as seen on this image: I managed to create evertyhing with SpannableStringBuilder, except the orange rounded rectangle. I can set the background to that color with BackgroundColorSpan, but I can't find a way to make it rounded. Any ideas how can I achieve this? Thanks in advance! EDIT: I'm using Xamarin.Android, but here is my code: stringBuilder.SetSpan(new BackgroundColorSpan(Application.Context.Resources.GetColor(Resource.Color.orangeColor)), stringBuilder.Length() - length, stringBuilder.Length(), SpanTypes.ExclusiveExclusive); jkincali If anyone's

TextView with different textSize

試著忘記壹切 提交于 2019-11-26 15:20:26
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 ? Michele Try span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); I know very late to answer but people are still might have the same question.Even I struggled a lot on this. Suppose you

spannable on android for textView

旧街凉风 提交于 2019-11-26 13:45:13
问题 Tweet o = tweets.get(position); TextView tt = (TextView) v.findViewById(R.id.toptext); //TextView bt = (TextView) v.findViewById(R.id.bottomtext); EditText bt =(EditText)findViewById(R.id.bottomtext); bt.setText(o.author); Spannable spn = (Spannable) bt.getText(); spn.setSpan(new StyleSpan(android.graphics.Typeface.BOLD_ITALIC) , 0, 100, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); //bt.setText(o.author); tt.setText(o.content); I'm setting twitter data in my Android application. I want to make the

How to click or tap on a TextView text on different words?

岁酱吖の 提交于 2019-11-26 12:25:01
问题 How to move to another view by click on text view with two different words. this is the string i am using. By clicking Sign Up, you are indicating that you have read and agree to the Term of Use and Privacy Policy. i want to make these two words (Term of Use, Privacy Policy) in different color and clickable.. i know ho to make color for a particular word. i want to make it clickable . 回答1: I finally figured it out how to have multiple clickable parts in a TextView. It is important that they

Android SpannableString set background behind part of text

纵饮孤独 提交于 2019-11-26 12:23:55
问题 I would like to create something similar as seen on this image: I managed to create evertyhing with SpannableStringBuilder, except the orange rounded rectangle. I can set the background to that color with BackgroundColorSpan, but I can\'t find a way to make it rounded. Any ideas how can I achieve this? Thanks in advance! EDIT: I\'m using Xamarin.Android, but here is my code: stringBuilder.SetSpan(new BackgroundColorSpan(Application.Context.Resources.GetColor(Resource.Color.orangeColor)),