We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextView 当设置了setMovementMethod方法后 在设置Ellipsize=end属性时 省略号不展示
The text was updated successfully, but these errors were encountered:
public class TextViewTouchListener implements View.OnTouchListener { Spannable spannable; public TextViewTouchListener(Spannable spannable) { this.spannable = spannable; } @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); if (!(v instanceof TextView)) { return false; } TextView textView = (TextView) v; if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { 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); if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(textView); } else if (action == MotionEvent.ACTION_DOWN) { Selection.setSelection(spannable, spannable.getSpanStart(link[0]), spannable.getSpanEnd(link[0])); } return true; } else { Selection.removeSelection(spannable); } } return false; } }
然后设置TextView,去掉setMovementMethod
textView.setText(str); textView.setOnTouchListener(new TextViewTouchListener(str));
Sorry, something went wrong.
No branches or pull requests
TextView 当设置了setMovementMethod方法后 在设置Ellipsize=end属性时 省略号不展示
The text was updated successfully, but these errors were encountered: