spannable

How to use support library fonts feature as a part of the TextView content (using spannable)?

白昼怎懂夜的黑 提交于 2019-12-18 05:52:14
问题 Background The support library (docs here) allows you to use TTF fonts files in the "res/font" folder, either in XML : app:fontFamily="@font/lato_black" or via code: val typeface = ResourcesCompat.getFont(context, R.font.lato_black) The problem While I know it's possible to use spannable technique to set different styles in parts of the TextView content (such as bold, italic, colors,etc...) , the only thing I've found for setting a different font, is by using the built in fonts of the OS, as

Rounded Background text like Instagram, ReplacementSpan not working as required

北战南征 提交于 2019-12-17 16:12:20
问题 I was trying to do something similar to Instagram below - But i want this curves like Instagram - Now i am stuck in one more problem - When i types,. text does not goes automatically to next line, I have to press return , like normally editText works in fixed width. (In short multiline is not working fine with ReplacementSpan ) Below is sample code for what i have done - public class EditextActivity extends AppCompatActivity { EditText edittext; RoundedBackgroundSpan roundedBackgroundSpan;

Android Spannable text save/store issue

梦想的初衷 提交于 2019-12-12 19:51:57
问题 I got a edittext and it has multiple coloured text like that code below. Is there any way to store text and colours and show them again? I used to use SharedPreference to store strings integers etc. but this isn`t working for Spannables. Spannable span1 = new SpannableString("this"); Spannable span2 = new SpannableString("is"); Spannable span3 = new SpannableString("text"); span1.setSpan(new ForegroundColorSpan(Color.parseColor("#292929")), 0, span1.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE

TextView#setMovementMethod(LinkMovementMethod.getInstance()) is breaking link display

醉酒当歌 提交于 2019-12-11 02:31:39
问题 I have a TextView that I am populating with a Spannable made from some HTML. This code: textView.setText(Html.fromHtml(textContent, mImageGetter, null)); displays links, but they aren't clickable. This code: text.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(Html.fromHtml(textContent, mImageGetter, null)); doesn't display the links. The TextView is specified in the XML as <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap

Any way to set span directly to spanable text?

倖福魔咒の 提交于 2019-12-10 20:01:52
问题 This may be a blunder,But I need to know... :) Iam develeoping an android application,In in I want to display two type face in a single textview and found this One very useful,A custom typeface span that extends typeface span, As per my understanding , we are creating a spannable as follows using two words String firstWord = "first "; String secondWord = "second"; // Create a new spannable with the two strings Spannable spannable = new SpannableString(firstWord+secondWord); then sets two type

MonoDroid GetSpans last parameter

回眸只為那壹抹淺笑 提交于 2019-12-10 14:55:19
问题 I'm trying to use ISpannable in a Monodroid project but am having problems with GetSpans. What I'm ultimately after is a Rich Text editor such as at: https://code.google.com/p/android-richtexteditor/source/browse/?r=4#svn/trunk/src/net/sgoliver However, the Xamarin documentation for GetSpans isn't particularly helpful. The line I'm trying to convert from Java to C# is: StyleSpan[] ss = s.getSpans(styleStart, position, StyleSpan.class); However, I don't know what to pass for the last parameter

How to alpha / translate animate each word in a TextView instead of each character?

半城伤御伤魂 提交于 2019-12-09 11:10:54
问题 I am working with the following Spannable and TextView like so and I've got it animating each character but I want to animate each word how can I accomplish that? Looking to alpha in and translate each word (from the bottom of the location of each word). By translating I mean a translate (move) animation. Source: private static class FadeyTextView extends TextView { private Interpolator mInterpolator; private long mStart, mDurationPerLetter; private boolean mAnimating = false; private

Paragraph spacings using SpannableStringBuilder in TextView

吃可爱长大的小学妹 提交于 2019-12-08 23:56:36
问题 As the question indicates, I am working on a TextView which will show formatted text using SpannableStringBuilder . It has multiple paragraphs and I would like to know what would be the easiest (or at least the least complicated) way to set spacing between paragraphs using some inbuilt span. Is this possible? Or will I be required to build a custom span class for this? 回答1: Implement the LineHeightSpan and override chooseHeight method as follows @Override public void chooseHeight(CharSequence

Android EditText: how to apply spans when composing?

对着背影说爱祢 提交于 2019-12-08 19:38:29
How can I apply spans on EditText text when the user is composing? For example the user has activated "bold" when composing, so every character input since then should be bold . I thought about adding text change listener to the EditText and update the text as the user composes, but I wanna know if there's a better way of doing this. The question was already answered in the comments, but to make it more permanent I will add a fuller answer. In order to set a span (like Bold) wherever the user is composing, you just set a span on the text at the cursor (or selection) position. StyleSpan

is Spannable text customizable? Android

吃可爱长大的小学妹 提交于 2019-12-08 08:42:56
问题 String aux = getInserzionista(offerta.getIdInserzionista()); sotto_titolo.setText("Offerta dal " + aux); int inizio = 12; int fine = 11+aux.length(); sotto_titolo.setMovementMethod(LinkMovementMethod.getInstance()); sotto_titolo.setText(sotto_titolo.getText().toString(),BufferType.SPANNABLE); Spannable mySpannable = (Spannable) sotto_titolo.getText(); ClickableSpan myClickableSpan = new ClickableSpan() { @Override public void onClick(View widget) { } }; //if i put this, not work mySpannable