spannablestring

How to break styled text into pages in Android?

喜夏-厌秋 提交于 2019-11-26 22:36:26
I have a long text which I want to break into multiple pages. Also I need a way to style this text. UPDATE: I created sample application , that shows how to use PageSplitter. How it works? Example application (Russian) - Cleverum . You need only PageSplitter class. Other code shows you how to use this class. import android.graphics.Typeface; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.TextPaint; import android.text.style.StyleSpan; import java.util.ArrayList; import java.util.List; public class PageSplitter { private final int pageWidth;

How to highlight Multiple words in EditText?

与世无争的帅哥 提交于 2019-11-26 21:57:55
问题 Currently I'm developing Spelling & Grammar checking app. It has EditText where user can input text & one button called "Check Text " upon click on button app will call LanguageTool API to check text & returns JSON response with result . Here is screenshot of app : Here is code which I have tried so far for highlighting multiple words but this code only highlights last word from array which I have created: for (int i = 0; i < errorStrings.size(); i++) { // Here textToCheck is EditText &

Spannable String only working for last Item in ListView

旧时模样 提交于 2019-11-26 18:37:55
问题 Edit: I'm now able to strike words in the listview but only able to do it from the bottom up and can only unstrike the bottom item afterwards. The code is below. @Override public View getView(int position, View convertView, ViewGroup parent) { final SubTask subTask = getItem(position); if(convertView == null){ convertView = LayoutInflater.from(getContext()).inflate(R.layout.subtask_adapter_list, parent, false); } final TextView tasksTitle = (TextView)convertView.findViewById(R.id.tasksName);

How to set multiple spans on a TextView's text on the same partial text?

☆樱花仙子☆ 提交于 2019-11-26 16:11:03
问题 Suppose I have the next text : Hello stackOverflow And I wish to set the second word to be both RelativeSizeSpan (to set a relative font size) and TextAppearanceSpan (to set the color of the text) , how do I merge them both ? All I know is that I can choose one of them , using the next code for example : final SpannableString textToShow = new SpannableString("Hello stackOverflow"); textToShow.setSpan(new RelativeSizeSpan(1.5f), textToShow.length() - "stackOverflow".length(),textToShow.length(

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)),

How to break styled text into pages in Android?

故事扮演 提交于 2019-11-26 09:46:20
问题 I have a long text which I want to break into multiple pages. Also I need a way to style this text. 回答1: UPDATE: I created sample application, that shows how to use PageSplitter. How it works? Example application (Russian) - Cleverum. You need only PageSplitter class. Other code shows you how to use this class. import android.graphics.Typeface; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.TextPaint; import android.text.style.StyleSpan;

SpannableStringBuilder to create String with multiple fonts/text sizes etc Example?

淺唱寂寞╮ 提交于 2019-11-26 08:49:43
问题 I need to create a String placed in a TextView that will display a string like this: First Part Not Bold BOLD rest not bold So I want to know how I could use SpannableStringBuilder to do this? I could use three TextEdit to accomplish this but I would like to use best solution. 回答1: First Part Not Bold BOLD rest not bold You can do this either as @Rajesh suggested or by this. String normalBefore= "First Part Not Bold "; String normalBOLD= "BOLD "; String normalAfter= "rest not bold"; String