Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have found a solution :-) Here it is, may be this will help other persons with the same problem than me !</p> <pre><code>// Initialize global value this.parentTextViewRect = new Rect(); // Initialize values for the computing of clickedText position SpannableString completeText = (SpannableString)(parentTextView).getText(); Layout textViewLayout = parentTextView.getLayout(); double startOffsetOfClickedText = completeText.getSpanStart(clickedText); double endOffsetOfClickedText = completeText.getSpanEnd(clickedText); double startXCoordinatesOfClickedText = textViewLayout.getPrimaryHorizontal((int)startOffsetOfClickedText); double endXCoordinatesOfClickedText = textViewLayout.getPrimaryHorizontal((int)endOffsetOfClickedText); // Get the rectangle of the clicked text int currentLineStartOffset = textViewLayout.getLineForOffset((int)startOffsetOfClickedText); int currentLineEndOffset = textViewLayout.getLineForOffset((int)endOffsetOfClickedText); boolean keywordIsInMultiLine = currentLineStartOffset != currentLineEndOffset; textViewLayout.getLineBounds(currentLineStartOffset, this.parentTextViewRect); // Update the rectangle position to his real position on screen int[] parentTextViewLocation = {0,0}; parentTextView.getLocationOnScreen(parentTextViewLocation); double parentTextViewTopAndBottomOffset = ( parentTextViewLocation[1] - parentTextView.getScrollY() + this.parentTextView.getCompoundPaddingTop() ); this.parentTextViewRect.top += parentTextViewTopAndBottomOffset; this.parentTextViewRect.bottom += parentTextViewTopAndBottomOffset; // In the case of multi line text, we have to choose what rectangle take if (keywordIsInMultiLine){ int screenHeight = this.mWindowManager.getDefaultDisplay().getHeight(); int dyTop = this.parentTextViewRect.top; int dyBottom = screenHeight - this.parentTextViewRect.bottom; boolean onTop = dyTop &gt; dyBottom; if (onTop){ endXCoordinatesOfClickedText = textViewLayout.getLineRight(currentLineStartOffset); } else{ this.parentTextViewRect = new Rect(); textViewLayout.getLineBounds(currentLineEndOffset, this.parentTextViewRect); this.parentTextViewRect.top += parentTextViewTopAndBottomOffset; this.parentTextViewRect.bottom += parentTextViewTopAndBottomOffset; startXCoordinatesOfClickedText = textViewLayout.getLineLeft(currentLineEndOffset); } } this.parentTextViewRect.left += ( parentTextViewLocation[0] + startXCoordinatesOfClickedText + this.parentTextView.getCompoundPaddingLeft() - parentTextView.getScrollX() ); this.parentTextViewRect.right = (int) ( this.parentTextViewRect.left + endXCoordinatesOfClickedText - startXCoordinatesOfClickedText ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload