Example usage for android.content.res TypedArray getColorStateList

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

Introduction

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

Prototype

@Nullable
public ColorStateList getColorStateList(@StyleableRes int index) 

Source Link

Document

Retrieve the ColorStateList for the attribute at index.

Usage

From source file:nccp.app.ui.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*w  ww.  ja va 2 s .  co m*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    //        setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
}

From source file:com.cytmxk.test.animation.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//www  .jav  a  2s .c o m

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();
}

From source file:com.android.messaging.ui.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/* w  w  w  . j ava2  s  .co m*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    if (OsUtil.isAtLeastL()) {
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRect(0, 0, view.getWidth(), view.getHeight());
            }
        });
    }
}

From source file:com.cytmxk.test.picture.blurpicture.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from   w  ww  .  ja v  a  2s .  c  o  m

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
}

From source file:com.frozendevs.periodictable.view.ViewPagerTabs.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from w ww.  j a v  a2s. c om

    mSidePadding = getResources().getDimensionPixelOffset(R.dimen.tab_side_padding);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    a.recycle();

    Resources.Theme theme = getContext().getTheme();
    TypedValue typedValue = new TypedValue();
    theme.resolveAttribute(R.attr.theme, typedValue, true);
    TypedArray typedArray = theme.obtainStyledAttributes(typedValue.resourceId,
            new int[] { R.attr.selectableItemBackground });
    mTextBackground = typedArray.getResourceId(0, 0);
    typedArray.recycle();

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // enable shadow casting from view bounds
        setOutlineProvider(new ViewOutlineProvider() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRect(0, 0, view.getWidth(), view.getHeight());
            }
        });
    }
}

From source file:me.henrytao.mdcore.core.MdLayoutInflaterFactory.java

protected void supportButton(Context context, Button button, AttributeSet attrs) {
    if (button == null) {
        return;//from ww  w.  j  a  v  a  2 s  .c o  m
    }
    ColorStateList textColor;
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, new int[] { android.R.attr.textColor },
            R.attr.buttonStyle, 0);
    try {
        textColor = MdCompat.getColorStateList(context, a.getResourceId(0, 0));
    } catch (Exception ignore) {
        textColor = a.getColorStateList(0);
    }
    a.recycle();
    if (textColor != null) {
        button.setTextColor(textColor);
    }
}

From source file:net.kjmaster.cookiemom.ui.numberpicker.NumberPickerDialogFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle args = getArguments();//from   ww  w  .j  ava 2s  .  co m
    if (args != null && args.containsKey(REFERENCE_KEY)) {
        mReference = args.getInt(REFERENCE_KEY);
    }
    if (args != null && args.containsKey(THEME_RES_ID_KEY)) {
        mTheme = args.getInt(THEME_RES_ID_KEY);
    }
    if (args != null && args.containsKey(PLUS_MINUS_VISIBILITY_KEY)) {
        mPlusMinusVisibility = args.getInt(PLUS_MINUS_VISIBILITY_KEY);
    }
    if (args != null && args.containsKey(DECIMAL_VISIBILITY_KEY)) {
        mDecimalVisibility = args.getInt(DECIMAL_VISIBILITY_KEY);
    }
    if (args != null && args.containsKey(MIN_NUMBER_KEY)) {
        mMinNumber = args.getInt(MIN_NUMBER_KEY);
    }
    if (args != null && args.containsKey(MAX_NUMBER_KEY)) {
        mMaxNumber = args.getInt(MAX_NUMBER_KEY);
    }
    if (args != null && args.containsKey(LABEL_TEXT_KEY)) {
        mLabelText = args.getString(LABEL_TEXT_KEY);
    }

    setStyle(DialogFragment.STYLE_NO_TITLE, 0);

    // Init defaults
    mTextColor = getResources().getColorStateList(R.color.dialog_text_color_holo_dark);
    mButtonBackgroundResId = R.drawable.button_background_dark;
    mDividerColor = getResources().getColor(R.color.default_divider_color_dark);
    mDialogBackgroundResId = R.drawable.dialog_full_holo_dark;

    if (mTheme != -1) {
        TypedArray a = getActivity().getApplicationContext().obtainStyledAttributes(mTheme,
                R.styleable.BetterPickersDialogFragment);

        mTextColor = a.getColorStateList(R.styleable.BetterPickersDialogFragment_bpTextColor);
        mButtonBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpButtonBackground,
                mButtonBackgroundResId);
        mDividerColor = a.getColor(R.styleable.BetterPickersDialogFragment_bpDividerColor, mDividerColor);
        mDialogBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpDialogBackground,
                mDialogBackgroundResId);
    }
}

From source file:dev.dworks.widgets.adateslider.PickerDialogFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle args = getArguments();/*from w  w w. j av  a2s .  c om*/
    if (args != null && args.containsKey(REFERENCE_KEY)) {
        mLayoutID = args.getInt(REFERENCE_KEY);
    }
    if (args != null && args.containsKey(THEME_RES_ID_KEY)) {
        mTheme = args.getInt(THEME_RES_ID_KEY);
    }
    if (args != null && args.containsKey(INITIAL_TIME_KEY)) {
        mInitialTime = (Calendar) args.getSerializable(INITIAL_TIME_KEY);
    }
    if (args != null && args.containsKey(MIN_TIME_KEY)) {
        minTime = (Calendar) args.getSerializable(MIN_TIME_KEY);
    }
    if (args != null && args.containsKey(MAX_TIME_KEY)) {
        maxTime = (Calendar) args.getSerializable(MAX_TIME_KEY);
    }
    if (args != null && args.containsKey(MINUTE_INTERVAL_KEY)) {
        this.minuteInterval = args.getInt(MINUTE_INTERVAL_KEY);
    }

    mInitialTime = Calendar.getInstance(mInitialTime.getTimeZone());
    mInitialTime.setTimeInMillis(mInitialTime.getTimeInMillis());

    if (minuteInterval > 1) {
        int minutes = mInitialTime.get(Calendar.MINUTE);
        int diff = ((minutes + minuteInterval / 2) / minuteInterval) * minuteInterval - minutes;
        mInitialTime.add(Calendar.MINUTE, diff);
    }
    setStyle(DialogFragment.STYLE_NO_TITLE, 0);

    // Init defaults
    mTextColor = getResources().getColorStateList(R.color.dialog_text_color_holo_dark);
    mButtonBackgroundResId = R.drawable.button_background_dark;
    mDividerColor = getResources().getColor(R.color.default_divider_color_dark);
    mDialogBackgroundResId = R.drawable.dialog_full_holo_dark;

    if (savedInstanceState != null) {
        Calendar c = (Calendar) savedInstanceState.getSerializable("time");
        if (c != null) {
            mInitialTime = c;
        }
    }

    if (mTheme != -1) {

        TypedArray a = getActivity().getApplicationContext().obtainStyledAttributes(mTheme,
                R.styleable.PickersDialogFragment);

        mTextColor = a.getColorStateList(R.styleable.PickersDialogFragment_textColor);
        mButtonBackgroundResId = a.getResourceId(R.styleable.PickersDialogFragment_buttonBackground,
                mButtonBackgroundResId);
        mDividerColor = a.getColor(R.styleable.PickersDialogFragment_dividerColor, mDividerColor);
        mDialogBackgroundResId = a.getResourceId(R.styleable.PickersDialogFragment_dialogBackground,
                mDialogBackgroundResId);
        a.recycle();
    }
}

From source file:com.mobileglobe.android.customdialer.common.list.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//  w  w w .ja va  2 s  . c  o m

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    if (CompatUtils.isLollipopCompatible()) {
        // enable shadow casting from view bounds
        setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
    }
}

From source file:com.android.contacts.common.list.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*  w  w  w. j a v a  2  s. com*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    if (CompatUtils.isLollipopCompatible()) {
        // enable shadow casting from view bounds
        setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
    }
}