List of usage examples for android.content.res TypedArray getColorStateList
@Nullable public ColorStateList getColorStateList(@StyleableRes int index)
From source file:com.commonsware.cwac.crossport.design.widget.FloatingActionButton.java
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // ThemeUtils.checkAppCompatTheme(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton); mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_android_backgroundTint); mBackgroundTintMode = ViewUtils/*from www. j a v a2s. c o m*/ .parseTintMode(a.getInt(R.styleable.FloatingActionButton_android_backgroundTintMode, -1), null); mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0); mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO); mCustomSize = a.getDimensionPixelSize(R.styleable.FloatingActionButton_fabCustomSize, 0); mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0); final float elevation = a.getDimension(R.styleable.FloatingActionButton_android_elevation, 0f); final float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f); mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false); a.recycle(); /* mImageHelper = new AppCompatImageHelper(this); mImageHelper.loadFromAttributes(attrs, defStyleAttr); */ mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size); getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth); getImpl().setElevation(elevation); getImpl().setPressedTranslationZ(pressedTranslationZ); }
From source file:com.shine.demo.viewpager.smartTabLayout.SmartTabLayout.java
public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); final DisplayMetrics dm = getResources().getDisplayMetrics(); final float density = dm.density; int tabBackgroundResId = NO_ID; boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS; ColorStateList textColors;//from w w w . j a va 2 s . co m float textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm); int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density); int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density); boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY; int customTabLayoutId = NO_ID; int customTabTextViewId = NO_ID; boolean clickable = TAB_CLICKABLE; int titleOffset = (int) (TITLE_OFFSET_DIPS * density); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0); tabBackgroundResId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_defaultTabBackground, tabBackgroundResId); textAllCaps = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps); textColors = a.getColorStateList(R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor); textSize = a.getDimension(R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize); textHorizontalPadding = a.getDimensionPixelSize( R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding); textMinWidth = a.getDimensionPixelSize(R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth, textMinWidth); customTabLayoutId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId, customTabLayoutId); customTabTextViewId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextViewId, customTabTextViewId); distributeEvenly = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly); clickable = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_clickable, clickable); titleOffset = a.getLayoutDimension(R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset); a.recycle(); this.titleOffset = titleOffset; this.tabViewBackgroundResId = tabBackgroundResId; this.tabViewTextAllCaps = textAllCaps; this.tabViewTextColors = (textColors != null) ? textColors : ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR); this.tabViewTextSize = textSize; this.tabViewTextHorizontalPadding = textHorizontalPadding; this.tabViewTextMinWidth = textMinWidth; this.internalTabClickListener = clickable ? new InternalTabClickListener() : null; this.distributeEvenly = distributeEvenly; if (customTabLayoutId != NO_ID) { setCustomTabView(customTabLayoutId, customTabTextViewId); } this.tabStrip = new SmartTabStrip(context, attrs); if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) { throw new UnsupportedOperationException( "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support"); } this.tabViewTextColors = new ColorStateList( new int[][] { new int[] { android.R.attr.state_pressed }, new int[] { android.R.attr.state_selected }, new int[] {} }, new int[] { Color.rgb(255, 111, 51), Color.rgb(255, 111, 51), Color.parseColor("#222222") }); // Make sure that the Tab Strips fills this View setFillViewport(!tabStrip.isIndicatorAlwaysInCenter()); addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }
From source file:com.github.takumalee.simplematerialtabpager.view.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/* w w w .j a va 2 s . co m*/ setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, SystemAttributes.ATTRS); tabTextSize = a.getDimensionPixelSize(SystemAttributes.TEXT_SIZE_INDEX, tabTextSize); ColorStateList colorStateList = a.getColorStateList(SystemAttributes.TEXT_COLOR_INDEX); int textPrimaryColor = a.getColor(SystemAttributes.TEXT_COLOR_PRIMARY, android.R.color.white); underlineColor = textPrimaryColor; dividerColor = textPrimaryColor; indicatorColor = textPrimaryColor; int padding = a.getDimensionPixelSize(SystemAttributes.PADDING_INDEX, 0); paddingLeft = padding > 0 ? padding : a.getDimensionPixelSize(SystemAttributes.PADDING_LEFT_INDEX, 0); paddingRight = padding > 0 ? padding : a.getDimensionPixelSize(SystemAttributes.PADDING_RIGHT_INDEX, 0); a.recycle(); // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle); tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD); tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD); tabTextColorSelected = a.getColorStateList(R.styleable.PagerSlidingTabStrip_pstsTextColorSelected); textAlpha = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, textAlpha); a.recycle(); tabTextColor = colorStateList == null ? getColorStateList(Color.argb(textAlpha, Color.red(textPrimaryColor), Color.green(textPrimaryColor), Color.blue(textPrimaryColor))) : colorStateList; tabTextColorSelected = tabTextColorSelected == null ? getColorStateList(textPrimaryColor) : tabTextColorSelected; setMarginBottomTabContainer(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:lewa.support.v7.widget.SwitchCompat.java
/** * Sets the switch text color, size, style, hint color, and highlight color * from the specified TextAppearance resource. *///w ww . j a v a 2 s .c om public void setSwitchTextAppearance(Context context, int resid) { TypedArray appearance = context.obtainStyledAttributes(resid, TEXT_APPEARANCE_ATTRS); ColorStateList colors; int ts; colors = appearance.getColorStateList(0); if (colors != null) { mTextColors = colors; } else { // If no color set in TextAppearance, default to the view's textColor mTextColors = getTextColors(); } ts = appearance.getDimensionPixelSize(1, 0); if (ts != 0) { if (ts != mTextPaint.getTextSize()) { mTextPaint.setTextSize(ts); requestLayout(); } } boolean allCaps = appearance.getBoolean(2, false); if (allCaps) { mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext()); } else { mSwitchTransformationMethod = null; } appearance.recycle(); }
From source file:com.eccyan.widget.SpinningTabStrip.java
public SpinningTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from ww w .j a va 2s . c om setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); flingVelocity = new Scroller(getContext()); flinger = new Flinger(); gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { flingVelocity.forceFinished(true); flingVelocity.fling(getScrollX(), getScrollY(), -(int) velocityX, -(int) velocityY, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, getHeight()); scrollStopped.set(false); Log.d(TAG, "scroll fling started"); return true; } @Override public boolean onDown(MotionEvent e) { if (!flingVelocity.isFinished()) { flingVelocity.forceFinished(true); } if (!flinger.isFinished()) { flinger.forceFinished(true); } return super.onDown(e); } }); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize); ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX); int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white); if (colorStateList != null) { tabTextColor = colorStateList; } else { tabTextColor = getColorStateList(textPrimaryColor); } underlineColor = textPrimaryColor; dividerColor = textPrimaryColor; indicatorColor = textPrimaryColor; // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.SpinningTabStrip); indicatorColor = a.getColor(R.styleable.SpinningTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.SpinningTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.SpinningTabStrip_pstsDividerColor, dividerColor); dividerWidth = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.SpinningTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.SpinningTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.SpinningTabStrip_pstsTextAllCaps, textAllCaps); tabTypefaceStyle = a.getInt(R.styleable.SpinningTabStrip_pstsTextStyle, Typeface.BOLD); tabTypefaceSelectedStyle = a.getInt(R.styleable.SpinningTabStrip_pstsTextSelectedStyle, Typeface.BOLD); tabTextAlpha = a.getFloat(R.styleable.SpinningTabStrip_pstsTextAlpha, HALF_TRANSP); tabTextSelectedAlpha = a.getFloat(R.styleable.SpinningTabStrip_pstsTextSelectedAlpha, OPAQUE); a.recycle(); setMarginBottomTabContainer(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.albedinsky.android.support.ui.widget.ViewPagerWidget.java
/** * Called from the constructor to process tint values for this view. <b>Note</b>, that for * {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} is this call ignored. * * @param context The context passed to constructor. * @param typedArray TypedArray obtained for styleable attributes specific for this view. */// w w w .j a v a 2s. c o m @SuppressWarnings("All") private void processTintValues(Context context, TypedArray typedArray) { // Do not handle for LOLLIPOP. if (UiConfig.LOLLIPOP) { return; } this.ensureTintInfo(); // Get tint colors. if (typedArray.hasValue(R.styleable.Ui_Widget_TextView_uiBackgroundTint)) { mTintInfo.backgroundTintList = typedArray .getColorStateList(R.styleable.Ui_Widget_TextView_uiBackgroundTint); } // Get tint modes. mTintInfo.backgroundTintMode = TintManager.parseTintMode( typedArray.getInt(R.styleable.Ui_Widget_TextView_uiBackgroundTintMode, 0), mTintInfo.backgroundTintList != null ? PorterDuff.Mode.SRC_IN : null); // If there is no tint mode specified within style/xml do not tint at all. if (mTintInfo.backgroundTintMode == null) { mTintInfo.backgroundTintList = null; } mTintInfo.hasBackgroundTintList = mTintInfo.backgroundTintList != null; mTintInfo.hasBackgroundTinMode = mTintInfo.backgroundTintMode != null; }
From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerView.java
public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(SUtils.createThemeWrapper(context, R.attr.sublimePickerStyle, R.style.SublimePickerStyleLight, defStyleAttr, R.style.DayPickerViewStyle), attrs); context = getContext();/*from w w w .ja v a2 s. c om*/ mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DayPickerView, defStyleAttr, R.style.DayPickerViewStyle); final int monthTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spMonthTextAppearance, R.style.SPMonthLabelTextAppearance); // verified final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spWeekDayTextAppearance, R.style.SPWeekDayLabelTextAppearance); // verified final int dayTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spDateTextAppearance, R.style.SPDayTextAppearance); final ColorStateList daySelectorColor = a.getColorStateList(R.styleable.DayPickerView_spDaySelectorColor); a.recycle(); if (Config.DEBUG) { Log.i(TAG, "MDayPickerView_spmMonthTextAppearance: " + monthTextAppearanceResId); Log.i(TAG, "MDayPickerView_spmWeekDayTextAppearance: " + dayOfWeekTextAppearanceResId); Log.i(TAG, "MDayPickerView_spmDateTextAppearance: " + dayTextAppearanceResId); } // Set up adapter. mAdapter = new DayPickerPagerAdapter(context, R.layout.date_picker_month_item, R.id.month_view); mAdapter.setMonthTextAppearance(monthTextAppearanceResId); mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId); mAdapter.setDayTextAppearance(dayTextAppearanceResId); mAdapter.setDaySelectorColor(daySelectorColor); final LayoutInflater inflater = LayoutInflater.from(context); int layoutIdToUse, viewPagerIdToUse; if (getTag() != null && getTag() instanceof String && getResources().getString(R.string.recurrence_end_date_picker_tag).equals(getTag())) { layoutIdToUse = R.layout.day_picker_content_redp; viewPagerIdToUse = R.id.redp_view_pager; } else { layoutIdToUse = R.layout.day_picker_content_sdp; viewPagerIdToUse = R.id.sdp_view_pager; } inflater.inflate(layoutIdToUse, this, true); OnClickListener onClickListener = new OnClickListener() { @Override public void onClick(View v) { final int direction; if (v == mPrevButton) { direction = -1; } else if (v == mNextButton) { direction = 1; } else { return; } // Animation is expensive for accessibility services since it sends // lots of scroll and content change events. final boolean animate = !mAccessibilityManager.isEnabled(); // ViewPager clamps input values, so we don't need to worry // about passing invalid indices. final int nextItem = mViewPager.getCurrentItem() + direction; mViewPager.setCurrentItem(nextItem, animate); } }; mPrevButton = (ImageButton) findViewById(R.id.prev); mPrevButton.setOnClickListener(onClickListener); mNextButton = (ImageButton) findViewById(R.id.next); mNextButton.setOnClickListener(onClickListener); ViewPager.OnPageChangeListener onPageChangedListener = new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { final float alpha = Math.abs(0.5f - positionOffset) * 2.0f; mPrevButton.setAlpha(alpha); mNextButton.setAlpha(alpha); } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageSelected(int position) { updateButtonVisibility(position); } }; mViewPager = (DayPickerViewPager) findViewById(viewPagerIdToUse); mViewPager.setAdapter(mAdapter); mViewPager.addOnPageChangeListener(onPageChangedListener); // Proxy the month text color into the previous and next buttons. if (monthTextAppearanceResId != 0) { final TypedArray ta = context.obtainStyledAttributes(null, ATTRS_TEXT_COLOR, 0, monthTextAppearanceResId); final ColorStateList monthColor = ta.getColorStateList(0); if (monthColor != null) { SUtils.setImageTintList(mPrevButton, monthColor); SUtils.setImageTintList(mNextButton, monthColor); } ta.recycle(); } // Proxy selection callbacks to our own listener. mAdapter.setDaySelectionEventListener(new DayPickerPagerAdapter.DaySelectionEventListener() { @Override public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) { if (mProxyDaySelectionEventListener != null) { mProxyDaySelectionEventListener.onDaySelected(DayPickerView.this, day); } } @Override public void onDateRangeSelectionStarted(@NonNull SelectedDate selectedDate) { if (mProxyDaySelectionEventListener != null) { mProxyDaySelectionEventListener.onDateRangeSelectionStarted(selectedDate); } } @Override public void onDateRangeSelectionEnded(@Nullable SelectedDate selectedDate) { if (mProxyDaySelectionEventListener != null) { mProxyDaySelectionEventListener.onDateRangeSelectionEnded(selectedDate); } } @Override public void onDateRangeSelectionUpdated(@NonNull SelectedDate selectedDate) { if (mProxyDaySelectionEventListener != null) { mProxyDaySelectionEventListener.onDateRangeSelectionUpdated(selectedDate); } } }); }
From source file:android.support.v7.widget.SwitchCompat.java
/** * Sets the switch text color, size, style, hint color, and highlight color * from the specified TextAppearance resource. *//* www .ja v a 2 s .com*/ public void setSwitchTextAppearance(Context context, int resid) { TypedArray appearance = context.obtainStyledAttributes(resid, R.styleable.TextAppearance); ColorStateList colors; int ts; colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColor); if (colors != null) { mTextColors = colors; } else { // If no color set in TextAppearance, default to the view's textColor mTextColors = getTextColors(); } ts = appearance.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0); if (ts != 0) { if (ts != mTextPaint.getTextSize()) { mTextPaint.setTextSize(ts); requestLayout(); } } int typefaceIndex, styleIndex; typefaceIndex = appearance.getInt(R.styleable.TextAppearance_android_typeface, -1); styleIndex = appearance.getInt(R.styleable.TextAppearance_android_textStyle, -1); setSwitchTypefaceByIndex(typefaceIndex, styleIndex); boolean allCaps = appearance.getBoolean(R.styleable.TextAppearance_textAllCaps, false); if (allCaps) { mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext()); } else { mSwitchTransformationMethod = null; } appearance.recycle(); }
From source file:android.support.v7ox.widget.SwitchCompat.java
/** * Sets the switch text color, size, style, hint color, and highlight color * from the specified TextAppearance resource. *///from w w w . j av a 2 s. com public void setSwitchTextAppearance(Context context, int resid) { TypedArray appearance = context.obtainStyledAttributes(resid, R.styleable.TextAppearance); ColorStateList colors; int ts; colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColor); if (colors != null) { mTextColors = colors; } else { // If no color set in TextAppearance, default to the view's textColor mTextColors = getTextColors(); } ts = appearance.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0); if (ts != 0) { if (ts != mTextPaint.getTextSize()) { mTextPaint.setTextSize(ts); requestLayout(); } } int typefaceIndex, styleIndex; typefaceIndex = appearance.getInt(R.styleable.TextAppearance_android_typeface, -1); styleIndex = appearance.getInt(R.styleable.TextAppearance_android_textStyle, -1); setSwitchTypefaceByIndex(typefaceIndex, styleIndex); boolean allCaps = appearance.getBoolean(R.styleable.TextAppearance_textAllCaps_ox, false); if (allCaps) { mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext()); } else { mSwitchTransformationMethod = null; } appearance.recycle(); }
From source file:com.tr4android.support.extension.picker.date.SimpleMonthView.java
/** * Applies the specified text appearance resource to a paint, returning the * text color if one is set in the text appearance. * * @param p the paint to modify//from w w w . jav a2 s .c o m * @param resId the resource ID of the text appearance * @return the text color, if available */ private ColorStateList applyTextAppearance(Paint p, int resId) { final TypedArray ta = getContext().obtainStyledAttributes(null, R.styleable.TextAppearance, 0, resId); final String fontFamily = ta.getString(R.styleable.TextAppearance_android_fontFamily); if (fontFamily != null) { p.setTypeface(Typeface.create(fontFamily, 0)); } p.setTextSize(ta.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, (int) p.getTextSize())); final ColorStateList textColor = ta.getColorStateList(R.styleable.TextAppearance_android_textColor); if (textColor != null) { final int enabledColor = textColor.getColorForState(ENABLED_STATE_SET, 0); p.setColor(enabledColor); } ta.recycle(); return textColor; }