5
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)

在 Android 的构造函数中StaticLayout,整数参数spacingmultspacingadd做什么?而且我也对includepad参数感到困惑。文档中没有解释。

4

1 回答 1

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
 */

这是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
 */

同样对于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
 */
于 2015-10-01T15:21:19.417 回答