List of usage examples for android.text Layout getLineBaseline
public final int getLineBaseline(int line)
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java
@Override public void OnListViewResize(int w, int h, int oldw, int oldh) { // detect keyboard launching if (oldh > h) { if (composingItem != null) { // When keyboard is up, adjust the scolling such that the cursor is always visible final int firstIndex = messageCenterListView.getFirstVisiblePosition(); int lastIndex = messageCenterListView.getLastVisiblePosition(); View v = messageCenterListView.getChildAt(lastIndex - firstIndex); int top = (v == null) ? 0 : v.getTop(); if (messageEditText != null) { int pos = messageEditText.getSelectionStart(); Layout layout = messageEditText.getLayout(); int line = layout.getLineForOffset(pos); int baseline = layout.getLineBaseline(line); int ascent = layout.getLineAscent(line); messageCenterViewHandler.sendMessage(messageCenterViewHandler.obtainMessage(MSG_SCROLL_FROM_TOP, lastIndex, Math.max(top - (oldh - h), baseline - ascent))); }// ww w. j av a 2s .c om } } }