use of android.content.res.ColorStateList in project philm by chrisbanes.
the class DrawableTintUtils method createFromColorRes.
public static Drawable createFromColorRes(@NonNull Context context, @DrawableRes int drawableId, @ColorRes int colorId) {
Drawable d = ContextCompat.getDrawable(context, drawableId);
d = DrawableCompat.wrap(d.mutate());
ColorStateList tint = AppCompatResources.getColorStateList(context, colorId);
DrawableCompat.setTintList(d, tint);
return d;
}
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);
}
}
use of android.content.res.ColorStateList in project android_frameworks_base by ParanoidAndroid.
the class FastScroller method init.
private void init(Context context) {
// Get both the scrollbar states drawables
TypedArray ta = context.getTheme().obtainStyledAttributes(ATTRS);
useThumbDrawable(context, ta.getDrawable(THUMB_DRAWABLE));
mTrackDrawable = ta.getDrawable(TRACK_DRAWABLE);
mOverlayDrawableLeft = ta.getDrawable(PREVIEW_BACKGROUND_LEFT);
mOverlayDrawableRight = ta.getDrawable(PREVIEW_BACKGROUND_RIGHT);
mOverlayPosition = ta.getInt(OVERLAY_POSITION, OVERLAY_FLOATING);
mScrollCompleted = true;
getSectionsFromIndexer();
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);
mPaint.setTextSize(mOverlaySize / 2);
ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
int textColorNormal = textColor.getDefaultColor();
mPaint.setColor(textColorNormal);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
// to show mOverlayDrawable properly
if (mList.getWidth() > 0 && mList.getHeight() > 0) {
onSizeChanged(mList.getWidth(), mList.getHeight(), 0, 0);
}
mState = STATE_NONE;
refreshDrawableState();
ta.recycle();
mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mMatchDragPosition = context.getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB;
setScrollbarPosition(mList.getVerticalScrollbarPosition());
}
use of android.content.res.ColorStateList in project android_frameworks_base by ParanoidAndroid.
the class TextView method getTextColors.
/**
* Returns the TextView_textColor attribute from the
* TypedArray, if set, or the TextAppearance_textColor
* from the TextView_textAppearance attribute, if TextView_textColor
* was not set directly.
*/
public static ColorStateList getTextColors(Context context, TypedArray attrs) {
ColorStateList colors;
colors = attrs.getColorStateList(com.android.internal.R.styleable.TextView_textColor);
if (colors == null) {
int ap = attrs.getResourceId(com.android.internal.R.styleable.TextView_textAppearance, -1);
if (ap != -1) {
TypedArray appearance;
appearance = context.obtainStyledAttributes(ap, com.android.internal.R.styleable.TextAppearance);
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColor);
appearance.recycle();
}
}
return colors;
}
use of android.content.res.ColorStateList in project android_frameworks_base by ParanoidAndroid.
the class TextView method setTextAppearance.
/**
* Sets the text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*/
public void setTextAppearance(Context context, int resid) {
TypedArray appearance = context.obtainStyledAttributes(resid, com.android.internal.R.styleable.TextAppearance);
int color;
ColorStateList colors;
int ts;
color = appearance.getColor(com.android.internal.R.styleable.TextAppearance_textColorHighlight, 0);
if (color != 0) {
setHighlightColor(color);
}
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColor);
if (colors != null) {
setTextColor(colors);
}
ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
if (ts != 0) {
setRawTextSize(ts);
}
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColorHint);
if (colors != null) {
setHintTextColor(colors);
}
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColorLink);
if (colors != null) {
setLinkTextColor(colors);
}
String familyName;
int typefaceIndex, styleIndex;
familyName = appearance.getString(com.android.internal.R.styleable.TextAppearance_fontFamily);
typefaceIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_typeface, -1);
styleIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_textStyle, -1);
setTypefaceFromAttrs(familyName, typefaceIndex, styleIndex);
final int shadowcolor = appearance.getInt(com.android.internal.R.styleable.TextAppearance_shadowColor, 0);
if (shadowcolor != 0) {
final float dx = appearance.getFloat(com.android.internal.R.styleable.TextAppearance_shadowDx, 0);
final float dy = appearance.getFloat(com.android.internal.R.styleable.TextAppearance_shadowDy, 0);
final float r = appearance.getFloat(com.android.internal.R.styleable.TextAppearance_shadowRadius, 0);
setShadowLayer(r, dx, dy, shadowcolor);
}
if (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false)) {
setTransformationMethod(new AllCapsTransformationMethod(getContext()));
}
appearance.recycle();
}
Aggregations