本文整理汇总了Java中android.text.Layout.getLineBaseline方法的典型用法代码示例。如果您正苦于以下问题:Java Layout.getLineBaseline方法的具体用法?Java Layout.getLineBaseline怎么用?Java Layout.getLineBaseline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.Layout
的用法示例。
在下文中一共展示了Layout.getLineBaseline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPopupChangePosition
import android.text.Layout; //导入方法依赖的package包/类
protected void onPopupChangePosition() {
try {
Layout layout = getLayout();
if (layout != null) {
int pos = getSelectionStart();
int line = layout.getLineForOffset(pos);
int baseline = layout.getLineBaseline(line);
int ascent = layout.getLineAscent(line);
float x = layout.getPrimaryHorizontal(pos);
float y = baseline + ascent;
int offsetHorizontal = (int) x + mLeftPadding;
setDropDownHorizontalOffset(offsetHorizontal);
int heightVisible = getHeightVisible();
int offsetVertical = (int) ((y + mCharHeight) - getScrollY());
int tmp = offsetVertical + getDropDownHeight() + mCharHeight;
if (tmp < heightVisible) {
tmp = offsetVertical + mCharHeight / 2;
setDropDownVerticalOffset(tmp);
} else {
tmp = offsetVertical - getDropDownHeight() - mCharHeight;
setDropDownVerticalOffset(tmp);
}
}
} catch (Exception ignored) {
//nothing
}
}
示例2: getDebugPosition
import android.text.Layout; //导入方法依赖的package包/类
/**
* @param line - current line
* @param column - column of line
* @return Position (in pixels) for edittext at line and column
*/
public Point getDebugPosition(int line, int column, int gravity) {
Layout layout = getLayout();
if (layout != null) {
int pos = layout.getLineStart(line) + column;
int baseline = layout.getLineBaseline(line);
int ascent = layout.getLineAscent(line);
int offsetHorizontal = (int) layout.getPrimaryHorizontal(pos) + mLinePadding; //x
float y;
int offsetVertical = 0;
if (gravity == Gravity.BOTTOM) {
y = baseline + ascent;
if (verticalScroll != null) {
offsetVertical = (int) ((y + mCharHeight) - verticalScroll.getScrollY());
} else {
offsetVertical = (int) ((y + mCharHeight) - getScrollY());
}
return new Point(offsetHorizontal, offsetVertical);
} else if (gravity == Gravity.TOP) {
y = layout.getLineTop(line);
if (verticalScroll != null) {
offsetVertical = (int) (y - verticalScroll.getScrollY());
} else {
offsetVertical = (int) (y - getScrollY());
}
return new Point(offsetHorizontal, offsetVertical);
}
return new Point(offsetHorizontal, offsetVertical);
}
return new Point();
}
示例3: onPopupChangePosition
import android.text.Layout; //导入方法依赖的package包/类
@Override
public void onPopupChangePosition() {
try {
Layout layout = getLayout();
if (layout != null) {
int pos = getSelectionStart();
int line = layout.getLineForOffset(pos);
int baseline = layout.getLineBaseline(line);
int ascent = layout.getLineAscent(line);
float x = layout.getPrimaryHorizontal(pos);
float y = baseline + ascent;
int offsetHorizontal = (int) x + mLinePadding;
setDropDownHorizontalOffset(offsetHorizontal);
int heightVisible = getHeightVisible();
int offsetVertical = 0;
if (verticalScroll != null) {
offsetVertical = (int) ((y + mCharHeight) - verticalScroll.getScrollY());
} else {
offsetVertical = (int) ((y + mCharHeight) - getScrollY());
}
int tmp = offsetVertical + getDropDownHeight() + mCharHeight;
if (tmp < heightVisible) {
tmp = offsetVertical + mCharHeight / 2;
setDropDownVerticalOffset(tmp);
} else {
tmp = offsetVertical - getDropDownHeight() - mCharHeight;
setDropDownVerticalOffset(tmp);
}
}
} catch (Exception ignored) {
}
}