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)
In the constructor for StaticLayout
in Android what do the integer parameters spacingmult
, and spacingadd
do? And I am also confused about the includepad
parameter, too. There is no explanation in the documentation.
It looks like spacingMult
changes the spacing by multiplying the spacing by the number provided, spacingAdd
adds the number provided to the original spacing value and includePad
factors in extra spacing for certain languages.
If Google doesn't have documentation for some things you are interested in, it is sometimes helpful to look at the comments in the source code. For example, if you look at the StaticLayout.java
file you will see that the Constructor calls another method with the spacingMult
and spacingAdd
parameters as that method's parameters. The comment for that method is as follows:
/**
* 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
*/
And here is the comment for setLineSpacing()
they mentioned within.
/**
* 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
*/
Likewise for 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
*/