/**
* Retrieve a dimensional unit attribute at <var>index</var>. Unit
* conversions are based on the current {@link DisplayMetrics}
* associated with the resources this {@link TypedArray} object
* came from.
*
* 通过指定的 参数inde 获得一个尺寸的单位属性。该单位转换是基于你当前机器屏幕的DisplayMetrics
* 以及和当前TypedArray 的对象持有的资源而得到的,
* <p>
* This method will throw an exception if the attribute is defined but is
* not a dimension.
* 当属性不是尺寸的时候,即使确实被定义了,也会抛出一个异常的。
* @param index Index of attribute to retrieve.
* @param defValue Value to return if the attribute is not defined or
* not a resource.
*
* @return Attribute dimension value multiplied by the appropriate
* metric, or defValue if not defined.
* 结果将被乘上一个合适的 metric
* @throws RuntimeException if the TypedArray has already been recycled.
* 如果当前TypedArray 被recycle 会抛异常
* @throws UnsupportedOperationException if the attribute is defined but is
* not an integer.
* 如果定义的属性不是整形,会抛异常
*
* @see #getDimensionPixelOffset
* @see #getDimensionPixelSize
*/
public float getDimension(int index, float defValue) {
if (mRecycled) {
throw new RuntimeException("Cannot make calls to a recycled instance!");
}
index *= AssetManager.STYLE_NUM_ENTRIES;
final int[] data = mData;
final int type = data[index+AssetManager.STYLE_TYPE];
if (type == TypedValue.TYPE_NULL) {
return defValue;
} else if (type == TypedValue.TYPE_DIMENSION) {
/**
* 这里就是我们获取结果走的方法
*/
return TypedValue.complexToDimension(
data[index + A