TextView textView = findViewById(R.id.text_view); Layout layout = textView.getLayout(); int lineCount = layout.getLineCount();
TextView textView = findViewById(R.id.text_view); Layout layout = textView.getLayout(); int lastLineStart = layout.getLineStart(layout.getLineCount()-1);In this example, we retrieve the TextView with id `text_view`, then get its layout and assign it to a `Layout` object. We can then use the `getLineStart()` method of the `Layout` object to get the starting position of the last line of text in the TextView. Package library: android.widget