Search in sources :

Example 51 with ColorStateList

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()));
}
Also used : ColorStateList(android.content.res.ColorStateList) SuppressLint(android.annotation.SuppressLint) AllCapsTransformationMethod(org.holoeverywhere.text.AllCapsTransformationMethod)

Example 52 with ColorStateList

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);
}
Also used : ColorStateList(android.content.res.ColorStateList) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 53 with ColorStateList

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);
}
Also used : ColorStateList(android.content.res.ColorStateList) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 54 with ColorStateList

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;
}
Also used : TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) Resources(android.content.res.Resources) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 55 with ColorStateList

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);
    }
}
Also used : OverlayItem(com.google.android.maps.OverlayItem) MapView(com.google.android.maps.MapView) ColorStateList(android.content.res.ColorStateList) Resources(android.content.res.Resources) GeoPoint(com.google.android.maps.GeoPoint) MapPinDrawable(greendroid.graphics.drawable.MapPinDrawable)

Aggregations

ColorStateList (android.content.res.ColorStateList)280 Paint (android.graphics.Paint)90 TypedArray (android.content.res.TypedArray)76 Drawable (android.graphics.drawable.Drawable)48 TextPaint (android.text.TextPaint)42 Resources (android.content.res.Resources)25 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)22 TypedValue (android.util.TypedValue)21 TextView (android.widget.TextView)19 Context (android.content.Context)18 SuppressLint (android.annotation.SuppressLint)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)13 AllCapsTransformationMethod (android.text.method.AllCapsTransformationMethod)13 RippleDrawable (android.graphics.drawable.RippleDrawable)12 StateListDrawable (android.graphics.drawable.StateListDrawable)12 View (android.view.View)12 Nullable (android.annotation.Nullable)10 Bitmap (android.graphics.Bitmap)10 TextAppearanceSpan (android.text.style.TextAppearanceSpan)9 PorterDuff (android.graphics.PorterDuff)8