Java Code Examples for android.widget.TextView#getTotalPaddingLeft()
The following examples show how to use
android.widget.TextView#getTotalPaddingLeft() .
These examples are extracted from open source projects.
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 Project: BigApp_Discuz_Android File: LinkTouchMovementMethod.java License: 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 2
Source Project: imsdk-android File: WorkWorldLinkTouchMovementMethod.java License: 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 3
Source Project: LinkTextView File: LinkTextView.java License: 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 4
Source Project: mvvm-template File: BetterLinkMovementExtended.java License: 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 5
Source Project: meiShi File: NameTouchMovementMethod.java License: 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 6
Source Project: SimpleText File: LinkTouchMovementMethod.java License: 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 7
Source Project: Klyph File: LinkMovementMethod.java License: 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 8
Source Project: imsdk-android File: LinkMovementClickMethod.java License: 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 9
Source Project: mOrgAnd File: OutlineItemView.java License: 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 10
Source Project: kaif-android File: ClickableSpanTouchListener.java License: 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 11
Source Project: JianshuApp File: LocalLinkMovementMethod.java License: 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 12
Source Project: social-text-view File: AccurateMovementMethod.java License: 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 13
Source Project: mimi-reader File: SelectableLinkMovementMethod.java License: 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 14
Source Project: BlackLight File: HackyMovementMethod.java License: 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 15
Source Project: BigApp_Discuz_Android File: WeiboTextView.java License: 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 16
Source Project: RichText File: LongClickableLinkMovementMethod.java License: 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 Project: Nimingban File: LinkMovementMethod2.java License: 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 18
Source Project: NewFastFrame File: CustomMoveMethod.java License: 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 19
Source Project: umeng_community_android File: TextViewFixTouchConsume.java License: 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 20
Source Project: BigApp_Discuz_Android File: TextViewFixTouchConsume.java License: 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); }