我想在代码中检索textApperanceLarge的int值。我用的下面的代码,但是并不能从TypedValue提取int值?
TypedValue typedValue = new TypedValue();
((Activity)context).getTheme().resolveAttribute(android.R.attr.textAppearanceLarge, typedValue, true);
如何修改代码实现这个方法?
我想在代码中检索textApperanceLarge的int值。我用的下面的代码,但是并不能从TypedValue提取int值?
TypedValue typedValue = new TypedValue();
((Activity)context).getTheme().resolveAttribute(android.R.attr.textAppearanceLarge, typedValue, true);
如何修改代码实现这个方法?
从 style 中获取 textSize 属性的值,添加下面的代码:
int[] textSizeAttr = new int[] { android.R.attr.textSize };
int indexOfAttrTextSize = 0;
TypedArray a = context.obtainStyledAttributes(typedValue.data, textSizeAttr);
int textSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1);
a.recycle();
你可以参考TextAppearance.Large