Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何让用户在listview或textview中进行突出显示、下划线或绘制等注释?_Android_Listview_Draw_Highlighting_Underline - Fatal编程技术网

Android 如何让用户在listview或textview中进行突出显示、下划线或绘制等注释?

Android 如何让用户在listview或textview中进行突出显示、下划线或绘制等注释?,android,listview,draw,highlighting,underline,Android,Listview,Draw,Highlighting,Underline,我想知道我是否可以允许用户在listview(或TextView)中执行某些操作: 提前感谢。要突出显示,请使用BackgroundColorSpan。要加下划线,请使用UnderlineSpan。对于绘图,您需要提供自定义解决方案。可以使用StaticLayout保存文本,并在自定义视图中触摸事件以在onDraw(画布)中绘制。一个StaticLayout可以处理跨度,因此它满足您的要求。对不起,我的英语不太好。我的意思是如何允许用户这样做?我的意思是如何允许用户这样做?是的,我的评论告诉您

我想知道我是否可以允许用户在listview(或TextView)中执行某些操作:


提前感谢。

要突出显示,请使用
BackgroundColorSpan
。要加下划线,请使用
UnderlineSpan
。对于绘图,您需要提供自定义解决方案。可以使用
StaticLayout
保存文本,并在自定义
视图中触摸事件以在
onDraw(画布)
中绘制。一个
StaticLayout
可以处理跨度,因此它满足您的要求。对不起,我的英语不太好。我的意思是如何允许用户这样做?
我的意思是如何允许用户这样做?
是的,我的评论告诉您如何让用户这样做。实施当然需要做大量的工作。据我所知,很难找到完全满足您需求的代码/库。好的,非常感谢!我会寻找更多的信息。
itemValue = "Your Hilighted Text";
if (itemValue != null) {
    int startPos = itemValue.toLowerCase(Locale.US).indexOf(getTextToFilter().toLowerCase(Locale.US));
    int endPos = startPos + getTextToFilter().length();
    if (startPos != -1) {
        Spannable spannable = new SpannableString(itemValue);
        ColorStateList blueColor = new ColorStateList(new int[][] { new int[] {}}, new int[] { Color.parseColor("#14A4D8") });
        TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, blueColor, null);
        spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        tvHilight.setText(spannable);
    } else
        tvHilight.setText(itemValue);
    }
}