Java 如何在Android中使用位图修改搜索栏?
我读了这篇很棒的文章,想在Java 如何在Android中使用位图修改搜索栏?,java,android,android-layout,bitmap,Java,Android,Android Layout,Bitmap,我读了这篇很棒的文章,想在TextView中添加气泡。在我的情况下,我确实有可编辑的,而不是文本视图。这是我的密码: private void setSpans(Editable s, @ColorInt int backgroundColor) { BackgroundColorSpan[] spans = s.getSpans(0, s.length(), BackgroundColorSpan.class); String[] words; if (s.toString()
TextView
中添加气泡。在我的情况下,我确实有可编辑的
,而不是文本视图
。这是我的密码:
private void setSpans(Editable s, @ColorInt int backgroundColor) {
BackgroundColorSpan[] spans = s.getSpans(0, s.length(), BackgroundColorSpan.class);
String[] words;
if (s.toString().endsWith(" ")) {
words = (s.toString() + "X").split("\\s");
} else {
words = s.toString().split("\\s");
}
int completedWordsCount = words.length - 1;
if (spans.length != completedWordsCount) {
for (BackgroundColorSpan span : spans) {
s.removeSpan(span);
}
int currentIndex = 0;
for (int i = 0; i < words.length - 1; i++) {
s.setSpan(new BackgroundColorSpan(backgroundColor), currentIndex, currentIndex + words[i].length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
currentIndex += words[i].length() + 1;
}
}
}
private void setspan(可编辑的s,@ColorInt backgroundColor){
BackgroundColorSpan[]span=s.getspan(0,s.length(),BackgroundColorSpan.class);
字符串[]个单词;
if(s.toString().endsWith(“”){
words=(s.toString()+“X”).split(\\s);
}否则{
words=s.toString().split(\\s);
}
int completedwordscont=words.length-1;
if(span.length!=completedWordsCount){
用于(背景色span:span){
s、 移除span(span);
}
int currentIndex=0;
for(int i=0;i
参考
如何使此可编辑
字段像上面粘贴的博客
一样工作。有没有办法在s.setSpan(新背景色SPAN(backgroundColor),currentIndex,currentIndex+words[i].length(),SPAN.SPAN_EXCLUSIVE_EXCLUSIVE)中添加椭圆形
代码>而不是背景色
我是Android位图的新手。我如何才能实现它?请参见DynamicDrawableSpan@pskink看着它DynamicDrawableSpan@pskink看看它