Android Text Layout Spacingmult和Spacingadd?

Nam*_*Lee 5 android android-layout staticlayout

public StaticLayout (CharSequence source, int bufstart, int bufend, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth)
Run Code Online (Sandbox Code Playgroud)

StaticLayoutAndroid 的构造函数中,做什么整数参数spacingmult,并spacingadd做什么?我也对includepad参数感到困惑.文档中没有解释.

use*_*692 8

看起来像是spacingMult通过将间距乘以提供spacingAdd的数量来更改间距,将提供的数量与原始间距值相加,并将includePad某些语言的额外间距中的因子相加.

如果Google没有您感兴趣的某些内容的文档,那么查看源代码中的注释有时会很有帮助.例如,如果查看该StaticLayout.java文件,您将看到构造函数使用spacingMultspacingAdd参数作为该方法的参数调用另一个方法.该方法的评论如下:

/**
* Set line spacing parameters. The default is 0.0 for {@code spacingAdd}
 * and 1.0 for {@code spacingMult}.
 *
 * @param spacingAdd line spacing add
 * @param spacingMult line spacing multiplier
 * @return this builder, useful for chaining
 * @see android.widget.TextView#setLineSpacing
 */
Run Code Online (Sandbox Code Playgroud)

这里是setLineSpacing()他们提到的评论.

/**
 * Sets line spacing for this TextView.  Each line will have its height
 * multiplied by <code>mult</code> and have <code>add</code> added to it.
 *
 * @attr ref android.R.styleable#TextView_lineSpacingExtra
 * @attr ref android.R.styleable#TextView_lineSpacingMultiplier
 */
Run Code Online (Sandbox Code Playgroud)

同样地includePad:

/**
 * Set whether to include extra space beyond font ascent and descent (which is
 * needed to avoid clipping in some languages, such as Arabic and Kannada). The
 * default is {@code true}.
 *
 * @param includePad whether to include padding
 * @return this builder, useful for chaining
 * @see android.widget.TextView#setIncludeFontPadding
 */
Run Code Online (Sandbox Code Playgroud)