2015-10-01 312 views
3
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參數感到困惑。文檔中沒有解釋。Android Text Layout Spacingmult和Spacingadd?

回答

8

看起來像spacingMult通過將間距乘以提供的數字來更改間距,spacingAdd將提供給原始間距值的數字與特定語言的額外間距中的因子相加。

如果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 
*/ 
+0

哦一個很好的提示,我應該嘗試更多的閱讀,謝謝 –