Example usage for android.content.res TypedArray getColor

List of usage examples for android.content.res TypedArray getColor

Introduction

In this page you can find the example usage for android.content.res TypedArray getColor.

Prototype

@ColorInt
public int getColor(@StyleableRes int index, @ColorInt int defValue) 

Source Link

Document

Retrieve the color value for the attribute at index.

Usage

From source file:com.astuetz.viewpager.extensions.IndicatorLineView.java

public IndicatorLineView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0);

    mLineColor = a.getColor(R.styleable.ViewPagerExtensions_lineColor, mLineColor);

    mFadeOutTime = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDelay, mFadeOutTime);

    mFadingDuration = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDuration, mFadingDuration);

    a.recycle();/*w w w  .ja  v  a2  s. c o  m*/
}

From source file:com.astuetz.viewpager.extensions.ProgressLineView.java

public ProgressLineView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0);

    mLineColor = a.getColor(R.styleable.ViewPagerExtensions_lineColor, mLineColor);

    mFadeOutTime = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDelay, mFadeOutTime);

    mFadingDuration = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDuration, mFadingDuration);

    a.recycle();/*from  w  w w. j  a v a  2s . c o  m*/
}

From source file:cn.finalteam.galleryfinal.widget.FloatingActionButton.java

void init(Context context, AttributeSet attributeSet) {
    TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.GFFloatingActionButton, 0, 0);
    mColorNormal = attr.getColor(R.styleable.GFFloatingActionButton_fabColorNormal, Color.BLACK);
    mColorPressed = attr.getColor(R.styleable.GFFloatingActionButton_fabColorPressed, Color.BLACK);
    mIcon = attr.getResourceId(R.styleable.GFFloatingActionButton_fabIcon, 0);
    mTitle = attr.getString(R.styleable.GFFloatingActionButton_fabTitle);
    attr.recycle();/*ww w . j  a v a 2 s.c  o m*/

    updateCircleSize();
    mShadowRadius = getDimension(R.dimen.fab_shadow_radius);
    mShadowOffset = getDimension(R.dimen.fab_shadow_offset);
    updateDrawableSize();

    updateBackground();
}

From source file:com.arbo.gaogao.widget.MyParallaxScrimageView.java

public MyParallaxScrimageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ParallaxScrimageView);
    if (a.hasValue(R.styleable.ParallaxScrimageView_scrimColor)) {
        scrimColor = a.getColor(R.styleable.ParallaxScrimageView_scrimColor, scrimColor);
    }/*from  ww w.  ja  v  a 2  s  . c  o m*/
    if (a.hasValue(R.styleable.ParallaxScrimageView_scrimAlpha)) {
        scrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_scrimAlpha, scrimAlpha);
    }
    if (a.hasValue(R.styleable.ParallaxScrimageView_maxScrimAlpha)) {
        maxScrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_maxScrimAlpha, maxScrimAlpha);
    }
    if (a.hasValue(R.styleable.ParallaxScrimageView_parallaxFactor)) {
        parallaxFactor = a.getFloat(R.styleable.ParallaxScrimageView_parallaxFactor, parallaxFactor);
    }
    a.recycle();

    scrimPaint = new Paint();
    scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha));
}

From source file:com.arbo.gaogao.widget.ParallaxScrimageView.java

public ParallaxScrimageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ParallaxScrimageView);
    if (a.hasValue(R.styleable.ParallaxScrimageView_scrimColor)) {
        scrimColor = a.getColor(R.styleable.ParallaxScrimageView_scrimColor, scrimColor);
    }/*  ww  w . j av a  2s .c o m*/
    if (a.hasValue(R.styleable.ParallaxScrimageView_scrimAlpha)) {
        scrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_scrimAlpha, scrimAlpha);
    }
    if (a.hasValue(R.styleable.ParallaxScrimageView_maxScrimAlpha)) {
        maxScrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_maxScrimAlpha, maxScrimAlpha);
    }
    if (a.hasValue(R.styleable.ParallaxScrimageView_parallaxFactor)) {
        parallaxFactor = a.getFloat(R.styleable.ParallaxScrimageView_parallaxFactor, parallaxFactor);
    }
    a.recycle();

    scrimPaint = new Paint();
    scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha));
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTextsView.java

void setTheme(TypedArray themeColors) {
    mPaint.setColor(themeColors.getColor(R.styleable.BetterPickersDialogs_bpRadialTextColor,
            ContextCompat.getColor(getContext(), R.color.bpBlue)));
}

From source file:com.astuetz.viewpager.extensions.ScrollingTabsView.java

public ScrollingTabsView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);

    this.mContext = context;

    mDividerMarginTop = (int) (getResources().getDisplayMetrics().density * mDividerMarginTop);
    mDividerMarginBottom = (int) (getResources().getDisplayMetrics().density * mDividerMarginBottom);
    mDividerWidth = (int) (getResources().getDisplayMetrics().density * mDividerWidth);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0);

    mDividerColor = a.getColor(R.styleable.ViewPagerExtensions_dividerColor, mDividerColor);

    mDividerMarginTop = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginTop,
            mDividerMarginTop);//from  w w w. jav a2 s  .co  m
    mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom,
            mDividerMarginBottom);

    mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable);

    a.recycle();

    this.setHorizontalScrollBarEnabled(false);
    this.setHorizontalFadingEdgeEnabled(false);

    mContainer = new LinearLayout(context);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);
    mContainer.setLayoutParams(params);
    mContainer.setOrientation(LinearLayout.HORIZONTAL);

    this.addView(mContainer);

}

From source file:com.fruit.widget.SlideSwitch.java

public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    listener = null;//www  .ja v  a2  s  . c om
    paint = new Paint();
    paint.setAntiAlias(true);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch);
    color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME);
    isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false);
    shape = a.getInt(R.styleable.slideswitch_shape, SHAPE_RECT);
    duration = a.getInt(R.styleable.slideswitch_duration, DURATION);
    a.recycle();
}

From source file:com.example.administrator.iclub21.view.SlideSwitch.java

public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    listener = null;/* w  ww. j  a v  a 2s .c  om*/
    paint = new Paint();
    paint.setAntiAlias(true);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch);
    color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME);
    isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false);
    shape = a.getInt(R.styleable.slideswitch_shape, SHAPE_RECT);
    a.recycle();
}

From source file:com.ereader.client.ui.view.TabsView.java

public TabsView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);

    this.mContext = context;

    mDividerMarginTop = (int) (getResources().getDisplayMetrics().density * mDividerMarginTop);
    mDividerMarginBottom = (int) (getResources().getDisplayMetrics().density * mDividerMarginBottom);
    mDividerWidth = (int) (getResources().getDisplayMetrics().density * mDividerWidth);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0);

    mDividerColor = a.getColor(R.styleable.ViewPagerExtensions_dividerColor, mDividerColor);

    mDividerMarginTop = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginTop,
            mDividerMarginTop);//from  ww  w  .ja v  a2  s .  c  o m
    mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom,
            mDividerMarginBottom);

    mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable);

    a.recycle();

    this.setHorizontalScrollBarEnabled(false);
    this.setHorizontalFadingEdgeEnabled(false);

    mContainer = new LinearLayout(context);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mContainer.setLayoutParams(params);
    mContainer.setOrientation(LinearLayout.HORIZONTAL);
    mContainer.setGravity(Gravity.CENTER);
    this.addView(mContainer);

}