Search in sources :

Example 1 with TypedArray

use of android.content.res.TypedArray in project android-betterpickers by code-troopers.

the class TimePicker method setTheme.

/**
     * Change the theme of the Picker
     *
     * @param themeResId the resource ID of the new style
     */
public void setTheme(int themeResId) {
    mTheme = themeResId;
    if (mTheme != -1) {
        TypedArray a = getContext().obtainStyledAttributes(themeResId, R.styleable.BetterPickersDialogFragment);
        mTextColor = a.getColorStateList(R.styleable.BetterPickersDialogFragment_bpTextColor);
        mKeyBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpKeyBackground, mKeyBackgroundResId);
        mButtonBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpButtonBackground, mButtonBackgroundResId);
        mDividerColor = a.getColor(R.styleable.BetterPickersDialogFragment_bpDividerColor, mDividerColor);
        mDeleteDrawableSrcResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpDeleteIcon, mDeleteDrawableSrcResId);
    }
    restyleViews();
}
Also used : TypedArray(android.content.res.TypedArray)

Example 2 with TypedArray

use of android.content.res.TypedArray in project photo-picker-plus-android by chute.

the class RippleView method init.

private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode())
        return;
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleView);
    rippleColor = typedArray.getColor(R.styleable.RippleView_rv_color, getResources().getColor(android.R.color.white));
    rippleType = typedArray.getInt(R.styleable.RippleView_rv_type, 0);
    hasToZoom = typedArray.getBoolean(R.styleable.RippleView_rv_zoom, false);
    isCentered = typedArray.getBoolean(R.styleable.RippleView_rv_centered, false);
    DURATION = typedArray.getInteger(R.styleable.RippleView_rv_rippleDuration, DURATION);
    FRAME_RATE = typedArray.getInteger(R.styleable.RippleView_rv_framerate, FRAME_RATE);
    PAINT_ALPHA = typedArray.getInteger(R.styleable.RippleView_rv_alpha, PAINT_ALPHA);
    ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleView_rv_ripplePadding, 0);
    canvasHandler = new Handler();
    zoomScale = typedArray.getFloat(R.styleable.RippleView_rv_zoomScale, 1.03f);
    zoomDuration = typedArray.getInt(R.styleable.RippleView_rv_zoomDuration, 200);
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(rippleColor);
    paint.setAlpha(PAINT_ALPHA);
    this.setWillNotDraw(false);
    gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public void onLongPress(MotionEvent event) {
            super.onLongPress(event);
            animateRipple(event);
            sendClickEvent(true);
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            return true;
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return true;
        }
    });
    this.setDrawingCacheEnabled(true);
    this.setClickable(true);
}
Also used : TypedArray(android.content.res.TypedArray) Handler(android.os.Handler) GestureDetector(android.view.GestureDetector) Paint(android.graphics.Paint) MotionEvent(android.view.MotionEvent)

Example 3 with TypedArray

use of android.content.res.TypedArray in project UltimateAndroid by cymcsg.

the class FlexibleSpaceToolbarScrollViewActivity method getActionBarSize.

private int getActionBarSize() {
    TypedValue typedValue = new TypedValue();
    int[] textSizeAttr = new int[] { R.attr.actionBarSize };
    int indexOfAttrTextSize = 0;
    TypedArray a = obtainStyledAttributes(typedValue.data, textSizeAttr);
    int actionBarSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1);
    a.recycle();
    return actionBarSize;
}
Also used : TypedArray(android.content.res.TypedArray) TypedValue(android.util.TypedValue)

Example 4 with TypedArray

use of android.content.res.TypedArray in project UltimateAndroid by cymcsg.

the class FlexibleSpaceWithImageListViewActivity method getActionBarSize.

private int getActionBarSize() {
    TypedValue typedValue = new TypedValue();
    int[] textSizeAttr = new int[] { R.attr.actionBarSize };
    int indexOfAttrTextSize = 0;
    TypedArray a = obtainStyledAttributes(typedValue.data, textSizeAttr);
    int actionBarSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1);
    a.recycle();
    return actionBarSize;
}
Also used : TypedArray(android.content.res.TypedArray) TypedValue(android.util.TypedValue)

Example 5 with TypedArray

use of android.content.res.TypedArray in project philm by chrisbanes.

the class AutofitTextView method init.

private void init(Context context, AttributeSet attrs, int defStyle) {
    float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
    boolean sizeToFit = true;
    int minTextSize = (int) scaledDensity * DEFAULT_MIN_TEXT_SIZE;
    float precision = PRECISION;
    if (attrs != null) {
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.AutofitTextView, defStyle, 0);
        sizeToFit = ta.getBoolean(R.styleable.AutofitTextView_sizeToFit, sizeToFit);
        minTextSize = ta.getDimensionPixelSize(R.styleable.AutofitTextView_minTextSize, minTextSize);
        precision = ta.getFloat(R.styleable.AutofitTextView_precision, precision);
        ta.recycle();
    }
    mPaint = new TextPaint();
    setSizeToFit(sizeToFit);
    setRawTextSize(super.getTextSize());
    setRawMinTextSize(minTextSize);
    setPrecision(precision);
}
Also used : TypedArray(android.content.res.TypedArray) TextPaint(android.text.TextPaint) TextPaint(android.text.TextPaint)

Aggregations

TypedArray (android.content.res.TypedArray)1991 Paint (android.graphics.Paint)190 TypedValue (android.util.TypedValue)185 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)162 Resources (android.content.res.Resources)118 View (android.view.View)116 Drawable (android.graphics.drawable.Drawable)114 XmlResourceParser (android.content.res.XmlResourceParser)80 Context (android.content.Context)78 ColorStateList (android.content.res.ColorStateList)78 AttributeSet (android.util.AttributeSet)78 IOException (java.io.IOException)77 SuppressLint (android.annotation.SuppressLint)66 TextPaint (android.text.TextPaint)63 TextView (android.widget.TextView)62 ViewGroup (android.view.ViewGroup)59 Bundle (android.os.Bundle)48 LayoutInflater (android.view.LayoutInflater)42 Point (android.graphics.Point)41 ImageView (android.widget.ImageView)40