TextView

771 阅读1分钟

零散的点

1. osColorControlNormal 及 osColorControlActivated
2. setElegantTextHeight
  • 设置TextView是否支持特定语言'高字体绘制/原始高度绘制'
  • TextView默认是关闭'原始高度绘制'的,会对特定语言文字进行压缩后绘制,有时候会导致设置为wrap_content的TextView文字显示不全.
  • Java及xml调用方式
/**
 * Set the TextView's elegant height metrics flag. This setting selects font
 * variants that have not been compacted to fit Latin-based vertical
 * metrics, and also increases top and bottom bounds to provide more space.
 *
 * @param elegant set the paint's elegant metrics flag.
 *
 * @see #isElegantTextHeight()
 * @see Paint#isElegantTextHeight()
 *
 * @attr ref android.R.styleable#TextView_elegantTextHeight
 */
public void setElegantTextHeight(boolean elegant) {
    if (elegant != mTextPaint.isElegantTextHeight()) {
        mTextPaint.setElegantTextHeight(elegant);
        if (mLayout != null) {
            nullLayouts();
            requestLayout();
            invalidate();
        }
    }
}

//java调用方式
tv.setElegantTextHeight(true);
***\SDK\platforms\android-30\data\res\values\attrs.xml
<declare-styleable name="TextAppearance">
        <!-- Elegant text height, especially for less compacted complex script text. -->
        <attr name="elegantTextHeight" format="boolean" />
</declare-styleable>

<!-- xml定义方式 -->
<TextView
    ***
    android:elegantTextHeight="true"
    />