spannable

Making text bold on a listview to a specify word dynamically

青春壹個敷衍的年華 提交于 2021-01-29 08:26:33
问题 I am trying to put color and bold up on a word that matches the word from a sentence in ArrayList items/value. what I have done so far is as below... so I have a String variable called filter "Hello" now I want to iterate through ArrayList itemList and find "Hello" from ArrayList items and make it bold and blue. String filter = "Hello"; String itemValue = "I just want to say Hello world! Hello"; itemList = new ArrayList<String>(); for(int i = 0; i<10; i++) { itemList.add("I just want to say

Android Spannable: how to clear color?

对着背影说爱祢 提交于 2020-04-15 18:25:32
问题 I have a Spannable set up on a SearchView for RecyclerView CardViews. If user-entered text is found on the CardView, the text is highlighted in red. When the SearchView line is cleared I would like the CardView text to return to the default Black color. Currently, the text is cleared and the color erroneously remains red. I tried to use "removeSpan" on the TextView but no luck. The TextView is "cardBlankText2". What am I missing here? RecyclerView Adapter file private List<ListItem>

android中用Spannable在TextView中设置超链接、颜色、字体

人盡茶涼 提交于 2020-02-28 23:51:42
昨晚研读 ApiDemo 源码至 com.example.android.apis.text.Link 类。首先,看一下其运行效果:   要给 TextView 加上效果,方式主要有几种:   第一种,自动应用效果,使用 android:autolink 属性,如:   Java代码 ? 代码片段,双击复制 01 02 03 04 05 06 07 08 09 10 11 android:id= "@+id/text1" android:layout_width= "match_parent" android:layout_height= "match_parent" android:autoLink= "all" android:text= "@string/link_text_auto" />   第二种,在文本中使用 标签,如:   Java代码 ? 代码片段,双击复制 01 02 03 04 05 06 07 text2: This is some other text, with a link specified via an tag. Use a \"tel:\" URL to dial a phone number   第三种,和第二种其实是一样的,只不过将文本改在 JAVA 代码中,如:   Java代码 ? 代码片段,双击复制 01 02 03 04 05 06

How to add a image inside a edit text android [duplicate]

左心房为你撑大大i 提交于 2020-01-15 16:48:40
问题 This question already has answers here : how to insert image to a editText (6 answers) Closed 4 years ago . I want to add image inside edittext view . For example i have image that size is 250*250 i want to show text left to image for height of 250 after that have to show text in normal left position. Some text some text some text Some image Some text some text some text Some text some text some text Some text some text some text Some text some text some text some text some text Some text

Custom sized italic Font using Spannable

末鹿安然 提交于 2020-01-04 06:06:00
问题 There is the following code: String s = message + "\n" + date; Spannable f = Spannable.Factory.getInstance().newSpannable(s); f.setSpan(new ForegroundColorSpan(Color.BLUE), 0, message.length(), 0); f.setSpan(new ForegroundColorSpan(Color.RED), message.length() + 1, s.length(), 0); textView.setText(f); This code works fine for setting up diffent colors for textView. But I need another feature - I'd like that "date" has got smaller size of font and italic typeface. How can I achieve that? 回答1:

how to add padding,stroke and radius to custom text with spannable

旧城冷巷雨未停 提交于 2020-01-03 06:06:13
问题 How can I add padding,corner and stroke to spannable text. The code below sets the backgroundcolorspan and custom font.I really appreciate any help. public class CustomTextView extends TextView { public CustomTextView(Context context) { super(context); setFont(); } public CustomTextView(Context context, AttributeSet attrs) { super(context, attrs); setFont(); } public CustomTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFont(); } private void

how to add padding,stroke and radius to custom text with spannable

▼魔方 西西 提交于 2020-01-03 06:06:09
问题 How can I add padding,corner and stroke to spannable text. The code below sets the backgroundcolorspan and custom font.I really appreciate any help. public class CustomTextView extends TextView { public CustomTextView(Context context) { super(context); setFont(); } public CustomTextView(Context context, AttributeSet attrs) { super(context, attrs); setFont(); } public CustomTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFont(); } private void

how set margin between spannable textview?

喜欢而已 提交于 2020-01-02 07:06:47
问题 I am trying to create spannable textview and showing it in EditText. So user can type something in EditText and if user pressed enter button of keyboard then i am converting this text in to spannable textview after this user can start typing again and press enter button of keyboard then again second spannable textview will create ans will show it in edittext but. Where i stuck? when i create two spannable textview then this two textview slightly overlapping on each other. And i want to set

How to handle onClick event on imageSpan in editText?

大憨熊 提交于 2020-01-02 02:28:05
问题 i am working on an app in which user choose an image from gallery and it will be added in editText, now i want if user click on image in editText it should open in fullScreen, i used below code :- public void addToEdt(Bitmap bitmap){ SpannableString ss = new SpannableString("abc"); Drawable d = new BitmapDrawable(getResources(), bitmap); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE); ss.setSpan(span, 0, 3,