android.text.Layout.getSecondaryHorizontal()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(204)

本文整理了Java中android.text.Layout.getSecondaryHorizontal()方法的一些代码示例,展示了Layout.getSecondaryHorizontal()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Layout.getSecondaryHorizontal()方法的具体详情如下:
包路径:android.text.Layout
类名称:Layout
方法名:getSecondaryHorizontal

Layout.getSecondaryHorizontal介绍

暂无

代码示例

代码示例来源:origin: facebook/litho

/**
 * {@link Layout#getPrimaryHorizontal} uses the paragraph direction, which is incorrect for
 * characters that oppose the direction of the paragraph.
 */
private float getHorizontal(int offset, int line) {
 final boolean isRtlLine = mLayout.getParagraphDirection(line) == Layout.DIR_RIGHT_TO_LEFT;
 return isRtlLine == mLayout.isRtlCharAt(offset)
   ? mLayout.getPrimaryHorizontal(offset)
   : mLayout.getSecondaryHorizontal(offset);
}

代码示例来源:origin: stackoverflow.com

if(getText().toString().substring(start,end).indexOf("\t")>=0
     || getText().toString().substring(start,end).indexOf("\n")>=0
     || getText().toString().substring(start,end).indexOf("\r")>=0) {
   TextPaint paint = new TextPaint();
   paint.setStyle(Paint.Style.FILL);
   paint.setColor(mBackgroundColor);
   paint.bgColor = mBackgroundColor;
   Layout layout = getLayout();
   int line = layout.getLineForOffset(start);
   int baseline = layout.getLineBaseline(line);
   int ascent = layout.getLineAscent(line);
   float x = layout.getPrimaryHorizontal(start);
   float y = baseline + ascent;
   Rect rect = new Rect();
   //rect.set(start, 0, Math.round(layout.getSecondaryHorizontal(end)), getLineHeight()+5);
   rect.set(start, 0, Math.round(layout.getSecondaryHorizontal(end)), getLineHeight()+5);
   rect.offset(Math.round(x), Math.round(y));
   Log.d("debug","tabs " + rect.toString());
   canvas.drawRect(rect, paint);
 }

代码示例来源:origin: TMLAndroid/FillBlankDemo

public RectF drawSpanRect(ReplaceSpan s) {
    Layout layout = mTv.getLayout();
    Spannable buffer = (Spannable) mTv.getText();
    int l = buffer.getSpanStart(s);
    int r = buffer.getSpanEnd(s);
    int line = layout.getLineForOffset(l);
    int l2 = layout.getLineForOffset(r);
    if (mRf == null){
      mRf = new RectF();
      //Rect rt = new Rect();
      Paint.FontMetrics fontMetrics = mTv.getPaint().getFontMetrics();
      //mTv.getPaint().getTextBounds("TgQyYFJ",0,7,rt);
      mFontT = (int) fontMetrics.ascent;
      mFontB  = (int) fontMetrics.descent;
    }
    mRf.left = layout.getPrimaryHorizontal(l);
    mRf.right = layout.getSecondaryHorizontal(r);
    // 通过基线去校准
    line = layout.getLineBaseline(line);
    mRf.top = line + mFontT;
    mRf.bottom = line + mFontB;
    return mRf;
}

代码示例来源:origin: crvv/android_wubi_input

final boolean isRtl = layout.isRtlCharAt(offset);
final float primary = layout.getPrimaryHorizontal(offset);
final float secondary = layout.getSecondaryHorizontal(offset);

相关文章