下面列出了android.widget.TextView#getCompoundPaddingTop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static int getRealTextViewHeight(@NonNull TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}
private boolean handleSelection(float x, float y, float rawX, float rawY) {
View view = mRecyclerView.findChildViewUnder(x, y);
if (view == null)
return mSelectionLongPressMode;
long id = mRecyclerView.getChildItemId(view);
int index = mRecyclerView.getChildAdapterPosition(view);
TextView textView = findTextViewIn(view);
if (textView == null)
return mSelectionLongPressMode;
textView.getLocationOnScreen(mTmpLocation);
float viewX = rawX - mTmpLocation[0];
float viewY = rawY - mTmpLocation[1];
float tViewY = Math.min(Math.max(viewY, 0), textView.getHeight() -
textView.getCompoundPaddingBottom()) - textView.getCompoundPaddingTop();
float tViewX = Math.min(Math.max(viewX, 0), textView.getWidth() -
textView.getCompoundPaddingRight()) - textView.getCompoundPaddingLeft();
mLastTouchTextId = id;
int line = textView.getLayout().getLineForVertical((int) tViewY);
mLastTouchTextOffset = textView.getLayout().getOffsetForHorizontal(line, tViewX);
mLastTouchInText = viewX >= textView.getCompoundPaddingLeft() &&
viewX <= textView.getWidth() - textView.getCompoundPaddingEnd() &&
viewY >= textView.getCompoundPaddingTop() &&
viewY <= textView.getHeight() - textView.getCompoundPaddingBottom() &&
tViewX <= textView.getLayout().getLineWidth(line);
if (mSelectionLongPressMode) {
long sel = TextSelectionHelper.getWordAt(textView.getText(), mLastTouchTextOffset,
mLastTouchTextOffset + 1);
int selStart = TextSelectionHelper.unpackTextRangeStart(sel);
int selEnd = TextSelectionHelper.unpackTextRangeEnd(sel);
int selLongPressIndex = getItemPosition(mSelectionLongPressId);
if (index > selLongPressIndex ||
(index == selLongPressIndex && selEnd >= mSelectionLongPressStart)) {
setSelection(mSelectionLongPressId, mSelectionLongPressStart,
mLastTouchTextId, selEnd);
} else {
setSelection(mLastTouchTextId, selStart,
mSelectionLongPressId, mSelectionLongPressEnd);
}
return true;
}
return false;
}
private static int getRealTextViewHeight(@NonNull TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}
private static int getRealTextViewHeight(@NonNull TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}
private static int getRealTextViewHeight(@NonNull TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}