Java Code Examples for android.widget.TextView#getTotalPaddingLeft()
The following examples show how to use
android.widget.TextView#getTotalPaddingLeft() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BetterLinkMovementExtended.java From mvvm-template with GNU General Public License v3.0 | 6 votes |
private BetterLinkMovementExtended.ClickableSpanWithText findClickableSpanUnderTouch(TextView textView, Spannable text, MotionEvent event) { int touchX = (int) event.getX(); int touchY = (int) event.getY(); touchX -= textView.getTotalPaddingLeft(); touchY -= textView.getTotalPaddingTop(); touchX += textView.getScrollX(); touchY += textView.getScrollY(); Layout layout = textView.getLayout(); int touchedLine = layout.getLineForVertical(touchY); int touchOffset = layout.getOffsetForHorizontal(touchedLine, (float) touchX); this.touchedLineBounds.left = layout.getLineLeft(touchedLine); this.touchedLineBounds.top = (float) layout.getLineTop(touchedLine); this.touchedLineBounds.right = layout.getLineWidth(touchedLine) + this.touchedLineBounds.left; this.touchedLineBounds.bottom = (float) layout.getLineBottom(touchedLine); if (this.touchedLineBounds.contains((float) touchX, (float) touchY)) { Object[] spans = text.getSpans(touchOffset, touchOffset, SPAN_CLASS); for (Object span : spans) { if (span instanceof ClickableSpan) { return ClickableSpanWithText.ofSpan(textView, (ClickableSpan) span); } } return null; } else { return null; } }
Example 2
Source File: LinkTextView.java From LinkTextView with MIT License | 6 votes |
private TouchableSpan getPressedSpan(TextView textView, Spannable spannable, MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); x -= textView.getTotalPaddingLeft(); y -= textView.getTotalPaddingTop(); x += textView.getScrollX(); y += textView.getScrollY(); Layout layout = textView.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); TouchableSpan[] link = spannable.getSpans(off, off, TouchableSpan.class); TouchableSpan touchedSpan = null; if (link.length > 0) { touchedSpan = link[0]; } return touchedSpan; }
Example 3
Source File: LinkTouchMovementMethod.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
TouchableSpan getPressedSpan(TextView textView, Spannable spannable, MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); x -= textView.getTotalPaddingLeft(); y -= textView.getTotalPaddingTop(); x += textView.getScrollX(); y += textView.getScrollY(); Layout layout = textView.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); TouchableSpan[] link = spannable.getSpans(off, off, TouchableSpan.class); TouchableSpan touchedSpan = null; if (link.length > 0) { touchedSpan = link[0]; } return touchedSpan; }
Example 4
Source File: WorkWorldLinkTouchMovementMethod.java From imsdk-android with MIT License | 6 votes |
/** * Copy from: * http://stackoverflow.com/questions/20856105/change-the-text-color-of-a-single-clickablespan-when-pressed-without-affecting-o * By: * Steven Meliopoulos */ private ClickableSpan getPressedSpan(TextView textView, Spannable spannable, MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); x -= textView.getTotalPaddingLeft(); y -= textView.getTotalPaddingTop(); x += textView.getScrollX(); y += textView.getScrollY(); Layout layout = textView.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = spannable.getSpans(off, off, ClickableSpan.class); ClickableSpan touchedSpan = null; if (link.length > 0) { touchedSpan = link[0]; } return touchedSpan; }
Example 5
Source File: OutlineItemView.java From mOrgAnd with GNU General Public License v2.0 | 5 votes |
@Override public boolean onTouch(View v, MotionEvent event) { boolean ret = false; CharSequence text = ((TextView) v).getText(); Spannable stext = Spannable.Factory.getInstance().newSpannable(text); TextView widget = (TextView) v; int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = stext.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } ret = true; } } return ret; }
Example 6
Source File: SelectableLinkMovementMethod.java From mimi-reader with Apache License 2.0 | 5 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } else if (action == MotionEvent.ACTION_DOWN) { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); } return true; } /*else { that's the line we need to remove Selection.removeSelection(buffer); }*/ } return super.onTouchEvent(widget, buffer, event); }
Example 7
Source File: AccurateMovementMethod.java From social-text-view with MIT License | 5 votes |
/** * Gets the span that was touched. * @param tv {@link TextView} * @param span {@link Spannable} * @param e {@link MotionEvent} * @return {@link TouchableSpan} */ private TouchableSpan getTouchedSpan(TextView tv, Spannable span, MotionEvent e) { // Find the location in which the touch was made int x = (int)e.getX(); int y = (int)e.getY(); // Ignore padding x -= tv.getTotalPaddingLeft(); y -= tv.getTotalPaddingTop(); // Account for scrollable text x += tv.getScrollX(); y += tv.getScrollY(); final Layout layout = tv.getLayout(); final int touchedLine = layout.getLineForVertical(y); final int touchOffset = layout.getOffsetForHorizontal(touchedLine, x); // Set bounds of the touched line touchBounds.left = layout.getLineLeft(touchedLine); touchBounds.top = layout.getLineTop(touchedLine); touchBounds.right = layout.getLineRight(touchedLine); touchBounds.bottom = layout.getLineBottom(touchedLine); // Ensure the span falls within the bounds of the touch TouchableSpan touchSpan = null; if (touchBounds.contains(x, y)) { // Find clickable spans that lie under the touched area TouchableSpan[] spans = span.getSpans(touchOffset, touchOffset, TouchableSpan.class); touchSpan = (spans.length > 0) ? spans[0] : null; } return touchSpan; }
Example 8
Source File: LocalLinkMovementMethod.java From JianshuApp with GNU General Public License v3.0 | 5 votes |
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action != MotionEvent.ACTION_UP && action != MotionEvent.ACTION_DOWN) { return Touch.onTouchEvent(widget, buffer, event); } int x = (((int) event.getX()) - widget.getTotalPaddingLeft()) + widget.getScrollX(); int y = (((int) event.getY()) - widget.getTotalPaddingTop()) + widget.getScrollY(); Layout layout = widget.getLayout(); int off = layout.getOffsetForHorizontal(layout.getLineForVertical(y), (float) x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } else { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); } if (!(widget instanceof TextViewFixTouchConsume)) { return true; } ((TextViewFixTouchConsume) widget).linkHit = true; return true; } Selection.removeSelection(buffer); Touch.onTouchEvent(widget, buffer, event); return false; }
Example 9
Source File: ClickableSpanTouchListener.java From kaif-android with Apache License 2.0 | 5 votes |
@Override public boolean onTouch(View v, MotionEvent event) { Spanned spanned = (Spanned) ((TextView) v).getText(); TextView widget = (TextView) v; int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = spanned.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } return true; } } return false; }
Example 10
Source File: LinkMovementClickMethod.java From imsdk-android with MIT License | 5 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { if(System.currentTimeMillis() - lastClickTime < CLICK_DELAY){ link[0].onClick(widget); } } else if (action == MotionEvent.ACTION_DOWN) { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); lastClickTime = System.currentTimeMillis(); } return true; } else { Selection.removeSelection(buffer); } } return super.onTouchEvent(widget, buffer, event); }
Example 11
Source File: LinkMovementMethod.java From Klyph with MIT License | 5 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } else if (action == MotionEvent.ACTION_DOWN) { /*Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0]));*/ } return false; } else { //Selection.removeSelection(buffer); } } //return super.onTouchEvent(widget, buffer, event); return false; }
Example 12
Source File: LinkTouchMovementMethod.java From SimpleText with Apache License 2.0 | 5 votes |
private CustomClickableSpan getPressedSpan(TextView textView, Spannable spannable, MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); x -= textView.getTotalPaddingLeft(); y -= textView.getTotalPaddingTop(); x += textView.getScrollX(); y += textView.getScrollY(); Layout layout = textView.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); CustomClickableSpan[] link = spannable.getSpans(off, off, CustomClickableSpan.class); CustomClickableSpan touchedSpan = null; if (link.length == 2) { touchedSpan = link[0]; CustomClickableSpan tempSpan = link[1]; touchedSpan.setOnTextClickListener(touchedSpan.getOnTextClickListener() != null ? touchedSpan.getOnTextClickListener() : tempSpan.getOnTextClickListener()); touchedSpan.setOnTextLongClickListener(touchedSpan.getOnTextLongClickListener() != null ? touchedSpan.getOnTextLongClickListener() : tempSpan.getOnTextLongClickListener()); } else if (link.length == 1){ touchedSpan = link[0]; } return touchedSpan; }
Example 13
Source File: NameTouchMovementMethod.java From meiShi with Apache License 2.0 | 5 votes |
private int getOffsetForHorizontal(TextView widget, MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); return layout.getOffsetForHorizontal(line, x); }
Example 14
Source File: LinkMovementMethod2.java From Nimingban with Apache License 2.0 | 4 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { ClickableSpan span = link[0]; if (span instanceof URLSpan) { OpenUrlHelper.openUrl(mActivity, ((URLSpan) span).getURL(), true); } else { span.onClick(widget); } } else if (action == MotionEvent.ACTION_DOWN) { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); } return true; } else { Selection.removeSelection(buffer); } } return super.onTouchEvent(widget, buffer, event); }
Example 15
Source File: CustomMoveMethod.java From NewFastFrame with Apache License 2.0 | 4 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable text, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // 这里得到的x , y值只是相对于屏幕的位置 int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int location = layout.getOffsetForHorizontal(layout.getLineForVertical(y), x); clickableSpans = text.getSpans(location, location, ClickableSpan.class); if (clickableSpans.length > 0) { isClickTextView = false; LogUtil.e("点击clickSpan位置"); // 选中点击位置 // Selection.setSelection(text, text.getSpanStart(clickableSpans[0]), text.getSpanEnd(clickableSpans[0])); text.setSpan(colorSpan = new BackgroundColorSpan(selectedColor), text.getSpanStart(clickableSpans[0]), text.getSpanEnd(clickableSpans[0]), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return true; } else { isClickTextView = true; } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: if (clickableSpans.length > 0) { LogUtil.e("点击span的up11"); // 设置点击时间 clickableSpans[0].onClick(widget); text.removeSpan(colorSpan); // Selection.removeSelection(text); return true; } else { LogUtil.e("点击textView文字的up11"); } break; default: if (colorSpan != null) { text.removeSpan(colorSpan); // Selection.removeSelection(text); return true; } break; } return super.onTouchEvent(widget, text, event); }
Example 16
Source File: LongClickableLinkMovementMethod.java From RichText with MIT License | 4 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); LongClickableSpan[] link = buffer.getSpans(off, off, LongClickableSpan.class); if (link.length != 0) { long currTime = System.currentTimeMillis(); LongClickableSpan l = link[0]; int ls = buffer.getSpanStart(l); int le = buffer.getSpanEnd(l); // 判断点击的点是否在Image范围内 ClickableImageSpan[] is = buffer.getSpans(ls, le, ClickableImageSpan.class); if (is.length > 0) { if (!is[0].clicked(x)) { Selection.removeSelection(buffer); return false; } } else if (off < layout.getOffsetToLeftOf(ls) || off > layout.getOffsetToLeftOf(le + 1)) { // 判断点击位置是否在链接范围内 Selection.removeSelection(buffer); return false; } if (action == MotionEvent.ACTION_UP) { // 如果按下时间超过500毫秒,触发长按事件 if (currTime - lastTime > MIN_INTERVAL) { if (!l.onLongClick(widget)) { // onLongClick返回false代表事件未处理,交由onClick处理 l.onClick(widget); } } else { l.onClick(widget); } } else { Selection.setSelection(buffer, ls, le); } lastTime = currTime; return true; } else { Selection.removeSelection(buffer); return false; } } return super.onTouchEvent(widget, buffer, event); }
Example 17
Source File: TextViewFixTouchConsume.java From umeng_community_android with MIT License | 4 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } else if (action == MotionEvent.ACTION_DOWN) { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); } if (widget instanceof TextViewFixTouchConsume) { ((TextViewFixTouchConsume) widget).mlinkHit = true; } return true; } else { Selection.removeSelection(buffer); Touch.onTouchEvent(widget, buffer, event); return false; } } return Touch.onTouchEvent(widget, buffer, event); }
Example 18
Source File: WeiboTextView.java From BigApp_Discuz_Android with Apache License 2.0 | 4 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); // LogUtils.printLog(WeiboTextView.class, "MotionEvent:" + action); // if (action == MotionEvent.ACTION_MOVE) { // isPressed = false; // } switch (action) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_UP: break; case MotionEvent.ACTION_CANCEL: buffer.setSpan(new BackgroundColorSpan(0x00000000), 0, weiboTextView.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Selection.setSelection(buffer, 0, weiboTextView.length()); break; } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { int start = buffer.getSpanStart(link[0]); int end = buffer.getSpanEnd(link[0]); // LogUtils.printLog(WebViewUtils.class, "start:" + start + " end:" + end); if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); buffer.setSpan(new BackgroundColorSpan(0x00000000), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Selection.setSelection(buffer, start, end); } else if (action == MotionEvent.ACTION_DOWN) { buffer.setSpan(new BackgroundColorSpan(weiboTextView.clickBgClolr), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Selection.setSelection(buffer, start, end); } if (widget instanceof WeiboTextView) { ((WeiboTextView) widget).linkHit = true; } return true; } else { Selection.removeSelection(buffer); Touch.onTouchEvent(widget, buffer, event); return false; } } return Touch.onTouchEvent(widget, buffer, event); }
Example 19
Source File: HackyMovementMethod.java From BlackLight with GNU General Public License v3.0 | 4 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { if (mGray == null) { mGray = new BackgroundColorSpan(widget.getContext().getResources().getColor(R.color.selector_gray)); } mIsLinkHit = false; int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) { int x = (int) event.getX(); int y = (int) event.getY(); if (DEBUG) { Log.d(TAG, "x = " + x + " y = " + y); } x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); if (DEBUG) { Log.d(TAG, "x = " + x + " y = " + y); } x += widget.getScrollX(); y += widget.getScrollY(); int line = widget.getLayout().getLineForVertical(y); int offset = widget.getLayout().getOffsetForHorizontal(line, x); ClickableSpan[] spans = buffer.getSpans(offset, offset, ClickableSpan.class); if (DEBUG) { Log.d(TAG, "x = " + x + " y = " + y); Log.d(TAG, "line = " + line + " offset = " + offset); Log.d(TAG, "spans.lenth = " + spans.length); } if (spans.length != 0) { int start = buffer.getSpanStart(spans[0]); int end = buffer.getSpanEnd(spans[0]); mIsLinkHit = true; if (action == MotionEvent.ACTION_DOWN) { if (DEBUG) { Log.d(TAG, "Down event detected"); } buffer.setSpan(mGray, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else if (action == MotionEvent.ACTION_UP) { if (DEBUG) { Log.d(TAG, "Up event detected"); } spans[0].onClick(widget); buffer.removeSpan(mGray); } return true; } } else { buffer.removeSpan(mGray); } return Touch.onTouchEvent(widget, buffer, event); }
Example 20
Source File: TextViewFixTouchConsume.java From BigApp_Discuz_Android with Apache License 2.0 | 4 votes |
@Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } else if (action == MotionEvent.ACTION_DOWN) { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); } if (widget instanceof TextViewFixTouchConsume) { ((TextViewFixTouchConsume) widget).linkHit = true; } return true; } else { Selection.removeSelection(buffer); Touch.onTouchEvent(widget, buffer, event); return false; } } return Touch.onTouchEvent(widget, buffer, event); }