當前位置: 首頁>>代碼示例>>Java>>正文


Java Layout.getLineBottom方法代碼示例

本文整理匯總了Java中android.text.Layout.getLineBottom方法的典型用法代碼示例。如果您正苦於以下問題:Java Layout.getLineBottom方法的具體用法?Java Layout.getLineBottom怎麽用?Java Layout.getLineBottom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.Layout的用法示例。


在下文中一共展示了Layout.getLineBottom方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findClosestLineBottom

import android.text.Layout; //導入方法依賴的package包/類
private int findClosestLineBottom( int ypos ) {
			
	Layout layout = this.childView.getLayout();
	
	if ( layout == null ) {
		return ypos;
	}
	
	int currentLine = layout.getLineForVertical(ypos);
	
	if ( currentLine > 0 ) {
		return layout.getLineBottom(currentLine -1);
	} else {
		return 0;
	}		
}
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:17,代碼來源:ScrollingStrategy.java

示例2: getScreenCoordsForPos

import android.text.Layout; //導入方法依賴的package包/類
private float[] getScreenCoordsForPos(int line, int pos)
{
	LayoutManager manager = getLayoutManager();
	ViewHolder holder = findViewHolderForAdapterPosition(line);
	if(holder == null)
	{
		if(getChildCount() > 0 && getChildAdapterPosition(getChildAt(getChildCount() - 1)) < line)
			return new float[]{getWidth() / 2, getHeight(), 0};
		return new float[]{getWidth() / 2, 0, 0};
	}
	View view = manager.findViewByPosition(findViewHolderForAdapterPosition(line).getLayoutPosition());
	if(view == null)
		return new float[]{0, 0, 0};
	Layout layout = ((TextView)view).getLayout();
	float x = layout.getPrimaryHorizontal(pos);
	int ln = layout.getLineForOffset(pos);
	float y = (float)(layout.getLineTop(ln) + layout.getLineBottom(ln)) / 2;
	float screenX = x + view.getLeft() + getScrollX();
	float screenY = y + view.getTop() + getScrollY();
	if(screenY < 0)
		screenY = 0;
	if(screenY > getBottom())
		screenY = getBottom();
	return new float[]{screenX, screenY, layout.getLineBottom(ln) - y};
}
 
開發者ID:mniip,項目名稱:bananapeel,代碼行數:26,代碼來源:SelectableScrollbackView.java

示例3: findClickableSpanUnderTouch

import android.text.Layout; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:27,代碼來源:BetterLinkMovementExtended.java

示例4: getFullyVisibleLinesCount

import android.text.Layout; //導入方法依賴的package包/類
/**
 * Get how many lines of text we can display so their full height is visible.
 */
private int getFullyVisibleLinesCount() {
    Layout layout = createWorkingLayout("");
    int height = getHeight() - getPaddingTop() - getPaddingBottom();
    int lineHeight = layout.getLineBottom(0);
    return height / lineHeight;
}
 
開發者ID:Ramotion,項目名稱:showroom-android,代碼行數:10,代碼來源:EllipsizingTextView.java

示例5: updatePosition

import android.text.Layout; //導入方法依賴的package包/類
public void updatePosition() {

		if ( storedPosition == -1 && this.storedPercentage == -1d ) {
			return;  //Hopefully come back later
		}

		if ( childView.getText().length() == 0 ) {
			return;
		}

		if ( storedPercentage != -1d ) {
			this.storedPosition = (int) (this.childView.getText().length() * storedPercentage);
			this.storedPercentage = -1d;
		}

		Layout layout = this.childView.getLayout();

		if ( layout != null ) {
			int pos = Math.max(0, this.storedPosition);
			int line = layout.getLineForOffset(pos);

			if ( line > 0 ) {
				int newPos = layout.getLineBottom(line -1);
				bookView.scrollTo(0, newPos);
			} else {
				bookView.scrollTo(0, 0);
			}
		}						 
	}
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:30,代碼來源:ScrollingStrategy.java

示例6: getTouchedSpan

import android.text.Layout; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:tylersuehr7,項目名稱:social-text-view,代碼行數:41,代碼來源:AccurateMovementMethod.java

示例7: isEventOnText

import android.text.Layout; //導入方法依賴的package包/類
/**
 * Check if event's coordinates are within line's text.
 *
 * Needed as getOffsetForHorizontal will return closest character,
 * which is an issue when clicking the empty space next to the text.
 */
private boolean isEventOnText(MotionEvent event, Layout layout, int line) {
    float left = layout.getLineLeft(line) + getTotalPaddingLeft();
    float right = layout.getLineRight(line) + getTotalPaddingRight();
    float bottom = layout.getLineBottom(line) + getTotalPaddingTop();
    float top = layout.getLineTop(line) + getTotalPaddingTop();

    return left <= event.getX() && event.getX() <= right &&
           top <= event.getY() && event.getY() <= bottom;
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:16,代碼來源:TextViewWithLinks.java

示例8: computeMaxLineCount

import android.text.Layout; //導入方法依賴的package包/類
private int computeMaxLineCount(Layout layout) {
  int availableHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
  for (int i = 0; i < layout.getLineCount(); i++) {
    if (availableHeight < layout.getLineBottom(i)) {
      return i;
    }
  }

  return layout.getLineCount();
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:11,代碼來源:EllipsizeTextView.java


注:本文中的android.text.Layout.getLineBottom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。