本文整理了Java中android.text.Layout.getLineTop()
方法的一些代码示例,展示了Layout.getLineTop()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Layout.getLineTop()
方法的具体详情如下:
包路径:android.text.Layout
类名称:Layout
方法名:getLineTop
暂无
代码示例来源:origin: Manabu-GT/ExpandableTextView
private static int getRealTextViewHeight(@NonNull TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 获取内容tv真实高度(含padding)
* @param textView
* @return
*/
private static int getRealTextViewHeight( TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}
代码示例来源:origin: nickbutcher/plaid
currentStartRunLeft = (int) (startMax ? startLayoutMaxLines
.getPrimaryHorizontal(i) : startLayout.getPrimaryHorizontal(i));
currentStartRunTop = startLayout.getLineTop(startLine);
currentEndLine = endLine;
currentEndRunLeft = (int) (endMax ? endLayoutMaxLines
.getPrimaryHorizontal(i) : endLayout.getPrimaryHorizontal(i));
currentEndRunTop = endLayout.getLineTop(endLine);
代码示例来源:origin: stackoverflow.com
Layout layout = edit.getLayout();
int topLine = layout.getLineTop(22);
代码示例来源:origin: stackoverflow.com
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
page.setSelection(pos, pos2);
Layout layout = page.getLayout();
scroll.scrollTo(0, layout.getLineTop(layout.getLineForOffset(pos2))); }
}, 500);
代码示例来源:origin: stackoverflow.com
Layout layout = textView.getLayout();
scrollView.scrollTo(0, layout.getLineTop(layout.getLineForOffset(startPos)));
代码示例来源:origin: stackoverflow.com
@Override
public void afterTextChanged(Editable editable) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Layout layout = textView.getLayout();
if (layout != null) {
int lineTop = layout.getLineTop(textView.getLineCount());
final int scrollAmount = lineTop + textView.getPaddingTop()
+ textView.getPaddingBottom() - textView.getBottom() + textView.getTop();
if (scrollAmount > 0) {
textView.scrollBy(0, scrollAmount);
} else {
textView.scrollTo(0, 0);
}
}
}
}, 1000L);
}
代码示例来源:origin: 121880399/QuickMvp
public void drawLeadingMargin(final Canvas c, final Paint p, int x, final int dir,
final int top, final int baseline, final int bottom,
final CharSequence text, final int start, final int end,
final boolean first, final Layout layout) {
int st = ((Spanned) text).getSpanStart(this);
int itop = layout.getLineTop(layout.getLineForOffset(st));
if (dir < 0)
x -= mBitmap.getWidth();
int delta = totalHeight - mBitmap.getHeight();
if (delta > 0) {
if (mVerticalAlignment == ALIGN_TOP) {
c.drawBitmap(mBitmap, x, itop, p);
} else if (mVerticalAlignment == ALIGN_CENTER) {
c.drawBitmap(mBitmap, x, itop + delta / 2, p);
} else {
c.drawBitmap(mBitmap, x, itop + delta, p);
}
} else {
c.drawBitmap(mBitmap, x, itop, p);
}
}
代码示例来源:origin: yoyiyi/bilisoleil
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir,
int top, int baseline, int bottom,
CharSequence text, int start, int end,
boolean first, Layout layout) {
int st = ((Spanned) text).getSpanStart(this);
int itop = layout.getLineTop(layout.getLineForOffset(st));
if (dir < 0)
x -= mBitmap.getWidth();
int delta = totalHeight - mBitmap.getHeight();
if (delta > 0) {
if (mVerticalAlignment == ALIGN_TOP) {
c.drawBitmap(mBitmap, x, itop, p);
} else if (mVerticalAlignment == ALIGN_CENTER) {
c.drawBitmap(mBitmap, x, itop + delta / 2, p);
} else {
c.drawBitmap(mBitmap, x, itop + delta, p);
}
} else {
c.drawBitmap(mBitmap, x, itop, p);
}
}
代码示例来源:origin: huangweicai/OkLibDemo
public void drawLeadingMargin(final Canvas c, final Paint p, int x, final int dir,
final int top, final int baseline, final int bottom,
final CharSequence text, final int start, final int end,
final boolean first, final Layout layout) {
int st = ((Spanned) text).getSpanStart(this);
int itop = layout.getLineTop(layout.getLineForOffset(st));
if (dir < 0)
x -= mBitmap.getWidth();
int delta = totalHeight - mBitmap.getHeight();
if (delta > 0) {
if (mVerticalAlignment == ALIGN_TOP) {
c.drawBitmap(mBitmap, x, itop, p);
} else if (mVerticalAlignment == ALIGN_CENTER) {
c.drawBitmap(mBitmap, x, itop + delta / 2, p);
} else {
c.drawBitmap(mBitmap, x, itop + delta, p);
}
} else {
c.drawBitmap(mBitmap, x, itop, p);
}
}
代码示例来源:origin: square1-io/rich-text-android
public void drawLeadingMargin(Canvas c,
Paint p,
int x,
int dir,
int top,
int baseline,
int bottom,
CharSequence text,
int start,
int end,
boolean first,
Layout layout) {
int st = ((Spanned) text).getSpanStart(this);
int itop = layout.getLineTop(layout.getLineForOffset(st));
if (dir < 0) {
x -= getBitmapW();
}
if(mQuoteSign != null) {
Rect rect = new Rect();
rect.left = (int)(x + mSignLeftPadding);
rect.top = (int)(itop + mSignTopPadding);
rect.right = rect.left + mQuoteSign.getIntrinsicWidth();
rect.bottom = rect.top + mQuoteSign.getIntrinsicHeight();
mQuoteSign.setBounds(rect);
mQuoteSign.draw(c);
//c.drawBitmap(mQuoteSign, x + mSignLeftPadding, itop + mSignTopPadding, p);
}
}
代码示例来源:origin: whyalwaysmea/BigBoom
/**
* 获取TextView真正的高度
*
* @param textView
* @return
*/
private static int getRealTextViewHeight(@NonNull TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}
代码示例来源:origin: chaychan/PowerfulViewLibrary
/**
* 获取内容tv真实高度(含padding)
* @param textView
* @return
*/
private static int getRealTextViewHeight( TextView textView) {
int textHeight = textView.getLayout().getLineTop(textView.getLineCount());
int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom();
return textHeight + padding;
}
代码示例来源:origin: baidu/speech-samples
private void scrollLog(String message) {
Spannable colorMessage = new SpannableString(message + "\n");
colorMessage.setSpan(new ForegroundColorSpan(0xff0000ff), 0, message.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mShowText.append(colorMessage);
Layout layout = mShowText.getLayout();
if (layout != null) {
int scrollAmount = layout.getLineTop(mShowText.getLineCount()) - mShowText.getHeight();
if (scrollAmount > 0) {
mShowText.scrollTo(0, scrollAmount + mShowText.getCompoundPaddingBottom());
} else {
mShowText.scrollTo(0, 0);
}
}
}
代码示例来源:origin: allenz8512/AndroidAppLog
@Override
public void afterTextChanged(final Editable s) {
final int scrollAmount = getLayout().getLineTop(getLineCount())
- getHeight();
if (scrollAmount > 0) {
scrollTo(0, scrollAmount);
} else {
scrollTo(0, 0);
}
}
});
代码示例来源:origin: hencoder/PracticeDraw5
@Override
protected void onDraw(Canvas canvas) {
Layout layout = getLayout();
bounds.left = layout.getLineLeft(1);
bounds.right = layout.getLineRight(1);
bounds.top = layout.getLineTop(1);
bounds.bottom = layout.getLineBottom(1);
canvas.drawRect(bounds, paint);
bounds.left = layout.getLineLeft(layout.getLineCount() - 4);
bounds.right = layout.getLineRight(layout.getLineCount() - 4);
bounds.top = layout.getLineTop(layout.getLineCount() - 4);
bounds.bottom = layout.getLineBottom(layout.getLineCount() - 4);
canvas.drawRect(bounds, paint);
super.onDraw(canvas);
}
}
代码示例来源:origin: redfish64/TinyTravelTracker
@Override
public void draw(Canvas canvas) {
final Layout layout = getLayout();
final RectF rect = mRect;
final int left = getCompoundPaddingLeft();
final int top = getExtendedPaddingTop();
rect.set(left + layout.getLineLeft(0) - PADDING_H,
top + layout.getLineTop(0) - PADDING_V,
Math.min(left + layout.getLineRight(0) + PADDING_H,
getScrollX() + getRight() - getLeft()),
top + layout.getLineBottom(0) + PADDING_V);
canvas.drawRoundRect(rect, CORNER_RADIUS, CORNER_RADIUS, mPaint);
super.draw(canvas);
}
}
代码示例来源:origin: hencoder/PracticeDraw5
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 把下面的绘制代码移到 super.onDraw() 的上面,就可以让原主体内容盖住你的绘制代码了
// (或者你也可以把 super.onDraw() 移到这段代码的下面)
Layout layout = getLayout();
bounds.left = layout.getLineLeft(1);
bounds.right = layout.getLineRight(1);
bounds.top = layout.getLineTop(1);
bounds.bottom = layout.getLineBottom(1);
canvas.drawRect(bounds, paint);
bounds.left = layout.getLineLeft(layout.getLineCount() - 3);
bounds.right = layout.getLineRight(layout.getLineCount() - 3);
bounds.top = layout.getLineTop(layout.getLineCount() - 3);
bounds.bottom = layout.getLineBottom(layout.getLineCount() - 3);
canvas.drawRect(bounds, paint);
}
}
代码示例来源:origin: MCMrARM/revolution-irc
private void showDropDown() {
updatePopupAnchor();
int h = Math.min(mCommandAdapter.getItemCount() * mPopupItemHeight, mMaxPopupHeight);
if (!mPopupWindow.isShowing()) {
mPopupWindow.setWidth(getWidth());
mPopupWindow.setHeight(h);
mPopupWindow.showAsDropDown(mPopupAnchor, 0,
getLayout().getLineTop(getLayout().getLineForOffset(getSelectionStart())));
} else {
mPopupWindow.update(mPopupAnchor, getWidth(), h);
}
}
代码示例来源:origin: MCMrARM/revolution-irc
textViewStart.getLocationOnScreen(mTmpLocation2);
outRect.top = mTmpLocation2[1] - mTmpLocation[1];
outRect.top += textViewStart.getLayout().getLineTop(lineStart);
内容来源于网络,如有侵权,请联系作者删除!