TypedArray - how to retrieve textStyle from xml (getInteger fails)

814 views Asked by At

textStyle is an Integer value, so following should work, shouldn't it?

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();

actually, tabTypefaceStyle always has the default value...

My Layout looks like the following:

<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" />

PS: even following fails:

TypedValue v = new TypedValue();
boolean s = a.getValue(2, v);

s is false....

0

There are 0 answers