use of android.content.res.ColorStateList in project HoloEverywhere by Prototik.
the class TextView method setTextAppearance.
public static <T extends android.widget.TextView & FontStyleProvider> void setTextAppearance(T textView, TypedArray appearance) {
int color = appearance.getColor(R.styleable.TextAppearance_android_textColorHighlight, 0);
if (color != 0) {
textView.setHighlightColor(color);
}
ColorStateList colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColor);
if (colors != null) {
textView.setTextColor(colors);
}
int ts = appearance.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);
if (ts != 0) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, ts);
}
colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColorHint);
if (colors != null) {
textView.setHintTextColor(colors);
}
colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColorLink);
if (colors != null) {
textView.setLinkTextColor(colors);
}
if (appearance.getBoolean(R.styleable.TextAppearance_android_textAllCaps, false)) {
textView.setTransformationMethod(new AllCapsTransformationMethod(textView.getContext()));
}
Object[] font = parseFontStyle(appearance);
textView.setFontStyle((String) font[2], (Integer) font[1] | ((Boolean) font[0] ? 0 : textView.getFontStyle()));
}
use of android.content.res.ColorStateList in project android_frameworks_base by ParanoidAndroid.
the class ColorStateListTest method testStateIsInList.
@SmallTest
public void testStateIsInList() throws Exception {
ColorStateList colorStateList = mResources.getColorStateList(R.color.color1);
int[] focusedState = { android.R.attr.state_focused };
int focusColor = colorStateList.getColorForState(focusedState, R.color.failColor);
assertEquals(mResources.getColor(R.color.testcolor1), focusColor);
}
use of android.content.res.ColorStateList in project android_frameworks_base by ParanoidAndroid.
the class ColorStateListTest method testEmptyState.
@SmallTest
public void testEmptyState() throws Exception {
ColorStateList colorStateList = mResources.getColorStateList(R.color.color1);
int[] emptyState = {};
int defaultColor = colorStateList.getColorForState(emptyState, mFailureColor);
assertEquals(mResources.getColor(R.color.testcolor2), defaultColor);
}
use of android.content.res.ColorStateList in project Jota-Text-Editor-old by jiro-aqua.
the class FastScroller method init.
private void init(Context context) {
// Get both the scrollbar states drawables
final Resources res = context.getResources();
useThumbDrawable(context, res.getDrawable(// Jota Text Editor
R.drawable.scrollbar_handle_accelerated_anim2));
// Jota Text Editor
// mOverlayDrawable = res.getDrawable(
// com.android.internal.R.drawable.menu_submenu_background);
mScrollCompleted = true;
getSectionsFromIndexer();
// Jota Text Editor
// mOverlaySize = context.getResources().getDimensionPixelSize(
// com.android.internal.R.dimen.fastscroll_overlay_size);
// mOverlayPos = new RectF();
mScrollFade = new ScrollFade();
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setTextAlign(Paint.Align.CENTER);
// Jota Text Editor
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary });
ColorStateList textColor = ta.getColorStateList(ta.getIndex(0));
int textColorNormal = textColor.getDefaultColor();
mPaint.setColor(textColorNormal);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mState = STATE_NONE;
}
use of android.content.res.ColorStateList in project GreenDroid by cyrilmottier.
the class MapPinMapActivity method onCreate.
//@formatter:on
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setActionBarContentView(R.layout.map_pin);
final MapView mapView = (MapView) findViewById(R.id.map_view);
mapView.setBuiltInZoomControls(true);
final Resources r = getResources();
for (int i = 0; i < sAreas.length; i++) {
final OverlayItem[] items = sAreas[i];
ColorStateList pinCsl = createRandomColorStateList();
ColorStateList dotCsl = createRandomColorStateList();
BasicItemizedOverlay itemizedOverlay = new BasicItemizedOverlay(new MapPinDrawable(r, pinCsl, dotCsl));
for (int j = 0; j < items.length; j++) {
itemizedOverlay.addOverlay(items[j]);
}
mapView.getOverlays().add(itemizedOverlay);
}
}
Aggregations