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参数感到困惑。文档中没有任何解释。

最佳答案

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

关于Android文本布局Spacingmult和Spacingadd?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32889061/

10-09 07:00