Android TypedArray-如何从xml检索textStyle(getInteger失败)
textStyle是一个整数值,所以下面应该可以工作,不是吗Android TypedArray-如何从xml检索textStyle(getInteger失败),android,xml,typedarray,Android,Xml,Typedarray,textStyle是一个整数值,所以下面应该可以工作,不是吗 private static final int[] ATTRS = new int[] { android.R.attr.textSize, android.R.attr.textColor, android.R.attr.textStyle }; TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.ge
private static final int[] ATTRS = new int[] {
android.R.attr.textSize,
android.R.attr.textColor,
android.R.attr.textStyle
};
TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
tabTextColor = a.getColor(1, tabTextColor);
tabTypefaceStyle = a.getInteger(2, tabTypefaceStyle);
a.recycle();
实际上,tabTypefaceStyle始终具有默认值
我的布局如下所示:
<com.astuetz.viewpager.extensions.PagerSlidingTabStrip
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="normal"
app:dividerColor="@color/white"
app:dividerPadding="2dp"
app:dividerPaddingBottom="8dp"
app:indicatorColor="@color/abs__holo_blue_light"
app:indicatorHeight="8dp"
app:tabPaddingLeftRight="5dip"
app:underlineColor="@color/abs__holo_blue_light" />
s为false…我将其添加到我的帖子中…当您将其更改为粗体或斜体时,您会得到什么?我使用粗体作为默认值。。。尝试在xml中使用斜体,但仍然没有设置正确的值。。。仍然获取默认值…请参阅
TypedValue v = new TypedValue();
boolean s = a.getValue(2, v);