android.content.res.ColorStateList Java Examples
The following examples show how to use
android.content.res.ColorStateList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoDetailsActivity.java From HeroVideo-master with Apache License 2.0 | 6 votes |
@Override public void loadData() { RetrofitHelper.getBiliAppAPI() .getVideoDetails(av) .compose(this.bindToLifecycle()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(videoDetails -> { mVideoDetailsInfo = videoDetails.getData(); LogUtil.test(" VideoDetails finishTask" + mVideoDetailsInfo.getTitle()); finishTask(); }, throwable -> { mFAB.setClickable(false); mFAB.setBackgroundTintList(ColorStateList.valueOf( getResources().getColor(R.color.gray_20))); }); }
Example #2
Source File: MyApp.java From Android-Skin with MIT License | 6 votes |
@Override public void onCreate() { super.onCreate(); // SpInstance.getInstance().init(getApplicationContext(),"skin_sp_file",false); AndroidSkin.getInstance().init(this); AndroidSkin.getInstance().addCustomAttrSupport(R.attr.tv_border_color, new ICustAttrApplyForColorListener<TestView>() { @Override public void applyColor(int attrId, TestView view, ColorStateList color) { view.setBorderColor(color.getDefaultColor()); } }); AndroidSkin.getInstance().addCustomAttrSupport(R.attr.tv_drawable_left_and_right, new TestViewDrawableLRListener()); }
Example #3
Source File: ReactTextInputPropertyTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testPlaceholderTextColor() { ReactEditText view = mManager.createViewInstance(mThemedContext); final ColorStateList defaultPlaceholderColorStateList = DefaultStyleValuesUtil.getDefaultTextColorHint( view.getContext()); ColorStateList colors = view.getHintTextColors(); assertThat(colors).isEqualTo(defaultPlaceholderColorStateList); mManager.updateProperties(view, buildStyles("placeholderTextColor", null)); colors = view.getHintTextColors(); assertThat(colors).isEqualTo(defaultPlaceholderColorStateList); mManager.updateProperties(view, buildStyles("placeholderTextColor", Color.RED)); colors = view.getHintTextColors(); assertThat(colors.getDefaultColor()).isEqualTo(Color.RED); mManager.updateProperties(view, buildStyles("placeholderTextColor", null)); colors = view.getHintTextColors(); assertThat(colors).isEqualTo(defaultPlaceholderColorStateList); }
Example #4
Source File: MainActivity.java From IdeaTrackerPlus with MIT License | 6 votes |
private void changeSecondaryColor() { //disable search mode for tabLayout disableSearchMode(); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout); tabLayout.setSelectedTabIndicatorColor(mSecondaryColor); mFab.setBackgroundTintList(ColorStateList.valueOf(mSecondaryColor)); if (rightDrawer != null) { mColorItem2.withIconColor(mSecondaryColor); rightDrawer.updateItem(mColorItem2); } RecyclerOnClickListener.setSecondaryColor(mSecondaryColor); }
Example #5
Source File: CalendarItemStyle.java From material-components-android with Apache License 2.0 | 6 votes |
private CalendarItemStyle( ColorStateList backgroundColor, ColorStateList textColor, ColorStateList strokeColor, int strokeWidth, ShapeAppearanceModel itemShape, @NonNull Rect insets) { Preconditions.checkArgumentNonnegative(insets.left); Preconditions.checkArgumentNonnegative(insets.top); Preconditions.checkArgumentNonnegative(insets.right); Preconditions.checkArgumentNonnegative(insets.bottom); this.insets = insets; this.textColor = textColor; this.backgroundColor = backgroundColor; this.strokeColor = strokeColor; this.strokeWidth = strokeWidth; this.itemShape = itemShape; }
Example #6
Source File: RadiusTextDelegate.java From UIWidget with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private ColorStateList getColorSelector(int normalColor, int pressedColor, int disabledColor, int selectedColor, int checkedColor) { return new ColorStateList( new int[][]{ new int[]{mStatePressed}, new int[]{mStateSelected}, new int[]{mStateChecked}, new int[]{mStateDisabled}, new int[]{} }, new int[]{ pressedColor, selectedColor, checkedColor, disabledColor, normalColor } ); }
Example #7
Source File: LoadingLayout.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
private void setTextColor(ColorStateList color) { if (null != mHeaderText) { mHeaderText.setTextColor(color); } if (null != mSubHeaderText) { mSubHeaderText.setTextColor(color); } }
Example #8
Source File: FloatingActionButton.java From floating-action-button with Apache License 2.0 | 5 votes |
/** * Sets color state list as background for this button. * <p/> * Xml attribute: {@code app:floatingActionButtonColor} * * @param colorStateList color */ public void setColorStateList(ColorStateList colorStateList) { boolean changed = mColorStateList != colorStateList; mColorStateList = colorStateList; if (changed) { updateBackground(); } }
Example #9
Source File: TabSwitcherStyle.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
/** * Returns the background color of tabs. * * @param tab * The tab, the background color should be returned for, as an instance of the class * {@link Tab} or null, if the background color should not be returned for a specific * tab * @return The background color of tabs as an instance of the class {@link ColorStateList} */ public final ColorStateList getTabBackgroundColor(@Nullable final Tab tab) { ColorStateList colorStateList = tab != null ? tab.getBackgroundColor() : null; if (colorStateList == null) { colorStateList = model.getTabBackgroundColor(); if (colorStateList == null) { colorStateList = themeHelper.getColorStateList(tabSwitcher.getLayout(), R.attr.tabSwitcherTabBackgroundColor); } } return colorStateList; }
Example #10
Source File: SublimeSubheaderItemView.java From SublimeNavigationView with Apache License 2.0 | 5 votes |
@Override public void setIconTintList(ColorStateList tintList) { mExpandDrawable = DrawableCompat.wrap(mExpandDrawable .getConstantState().newDrawable()).mutate(); DrawableCompat.setTintList(mExpandDrawable, tintList); mCollapseDrawable = DrawableCompat.wrap(mCollapseDrawable .getConstantState().newDrawable()).mutate(); DrawableCompat.setTintList(mCollapseDrawable, tintList); super.setIconTintList(tintList); }
Example #11
Source File: TabletTabRecyclerAdapter.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
/** * Adapts the color of a button, which allows to add a new tab. * * @param addTabItem * The add tab item, which corresponds to the button, whose color should be adapted, as * an instance of the class {@link AddTabItem}. The add tab item may not be null */ private void adaptAddTabButtonColor(@NonNull final AddTabItem addTabItem) { ColorStateList colorStateList = getStyle().getAddTabButtonColor(); int[] stateSet = new int[]{}; int color = colorStateList.getColorForState(stateSet, colorStateList.getDefaultColor()); View view = addTabItem.getView(); Drawable background = view.getBackground(); background.setColorFilter(color, PorterDuff.Mode.MULTIPLY); }
Example #12
Source File: ThreadActivity.java From redgram-for-reddit with GNU General Public License v3.0 | 5 votes |
private void setupFabs() { if(TRUE.equalsIgnoreCase(postItem.getLikes())){ upFab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.material_green700))); }else if(FALSE.equalsIgnoreCase(postItem.getLikes())){ downFab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.material_red700))); }else{ upFab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.material_bluegrey900))); downFab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.material_bluegrey900))); } }
Example #13
Source File: MaterialRadioButtonTest.java From material-components-android with Apache License 2.0 | 5 votes |
/** * Checks that the {@link MaterialRadioButton} buttonTint matches {@link * R.color#radiobutton_themeable_attribute_color}. */ static void testThemeableButtonTint(RadioButton radioButton) { ColorStateList buttonTintList = CompoundButtonCompat.getButtonTintList(radioButton); assertThat(buttonTintList.getColorForState(STATE_CHECKED, Color.BLACK)) .isEqualTo(MaterialColors.getColor(radioButton, R.attr.colorControlActivated)); assertThat(buttonTintList.getColorForState(STATE_UNCHECKED, Color.BLACK)) .isEqualTo(MaterialColors.getColor(radioButton, R.attr.colorOnSurface)); }
Example #14
Source File: SpeedyColorStateList.java From Android-SpeedyViewSelector with Apache License 2.0 | 5 votes |
public ColorStateList build(){ SpeedyArrayMap<int[], Integer> speedyArrayMap = mColorStateList.copy(); speedyArrayMap.put(mDefaultStateSet,mDefaultStateColor); int size = speedyArrayMap.size(); int[][] stateSet = new int[size][]; int [] colors = new int[size]; for (int index=0;index<size;index++){ stateSet[index] = speedyArrayMap.keyAt(index); colors[index] = speedyArrayMap.valueAt(index); } return new ColorStateList(stateSet,colors); }
Example #15
Source File: DotDrawable.java From ProjectX with Apache License 2.0 | 5 votes |
@Nullable private PorterDuffColorFilter getTintFilter(@Nullable ColorStateList tint, @Nullable PorterDuff.Mode tintMode, int defaultColor) { return tint == null || tintMode == null ? null : new PorterDuffColorFilter( tint.getColorForState(getState(), defaultColor), tintMode); }
Example #16
Source File: LoadingLayout.java From handmarkPulltorefreshLibrary with Apache License 2.0 | 5 votes |
private void setTextColor(ColorStateList color) { if (null != mHeaderText) { mHeaderText.setTextColor(color); } if (null != mSubHeaderText) { mSubHeaderText.setTextColor(color); } }
Example #17
Source File: TabSwitcherStyle.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
/** * Returns the color of the button, which allows to add a new tab. When using the smartphone * layout, such a button is never shown. When using the tablet layout, the button is shown next * to the tabs. * * @return The color of the button, which allows to add a new tab, as an instance of the class * {@link ColorStateList} or null, if the default color is used */ public final ColorStateList getAddTabButtonColor() { ColorStateList colorStateList = model.getAddTabButtonColor(); if (colorStateList == null) { colorStateList = themeHelper.getColorStateList(tabSwitcher.getLayout(), R.attr.tabSwitcherAddTabButtonColor); } return colorStateList; }
Example #18
Source File: KChartTabView.java From kAndroid with Apache License 2.0 | 5 votes |
public void setTextColor(ColorStateList color) { mColorStateList = color; for (int i = 0; i < mLlContainer.getChildCount(); i++) { TabView tabView = (TabView) mLlContainer.getChildAt(i); tabView.setTextColor(mColorStateList); } if (mColorStateList != null) { mTvFullScreen.setTextColor(mColorStateList); } }
Example #19
Source File: MessageRecyclerViewAdapter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
ErrorViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); errorTextView.setText(R.string.load_comments_failed); errorTextView.setTextColor(mSecondaryTextColor); retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore()); retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme)); retryButton.setTextColor(mButtonTextColor); }
Example #20
Source File: MenuItemsAdapter.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull MenuItemsAdapter.ViewHolder holder, int position) { final BaseDrawerItem<E> item = items.get(position); holder.icon.setImageResource(item.icon); holder.name.setText(item.name); if (item.badgeNumber >= 0) { holder.badge.setVisibility(View.VISIBLE); holder.badge.setText(String.valueOf(item.badgeNumber)); } else { holder.badge.setVisibility(View.GONE); } holder.itemView.setOnClickListener(v -> { if (listener != null) listener.onMenuItemSelected(item); }); if (item.active) { holder.name.setTextColor(colorAccent); holder.itemView.setBackgroundResource(R.drawable.item_drawer_active); holder.icon.setImageTintList(ColorStateList.valueOf(colorAccent)); } else { holder.name.setTextColor(colorTextPrimary); holder.icon.setImageTintList(ColorStateList.valueOf(colorTextPrimary)); CommonUtils.setBackground(holder.itemView, android.R.attr.selectableItemBackground); } if (width > 0) { holder.itemView.getLayoutParams().width = width; holder.itemView.requestLayout(); } }
Example #21
Source File: OutgoingMessageViewHolder.java From weMessage with GNU Affero General Public License v3.0 | 5 votes |
private Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor, @ColorInt int pressedColor, @DrawableRes int shape) { Drawable drawable = DrawableCompat.wrap(getVectorDrawable(shape)).mutate(); DrawableCompat.setTintList( drawable, new ColorStateList( new int[][]{ new int[]{android.R.attr.state_selected}, new int[]{android.R.attr.state_pressed}, new int[]{-android.R.attr.state_pressed, -android.R.attr.state_selected} }, new int[]{selectedColor, pressedColor, normalColor} )); return drawable; }
Example #22
Source File: NavigationViewUtil.java From a with GNU General Public License v3.0 | 5 votes |
public static void setItemIconColors(@NonNull NavigationView navigationView, @ColorInt int normalColor, @ColorInt int selectedColor) { final ColorStateList iconSl = new ColorStateList( new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ normalColor, selectedColor }); navigationView.setItemIconTintList(iconSl); }
Example #23
Source File: SublimeSubheaderItemView.java From SublimeNavigationView with Apache License 2.0 | 5 votes |
@Override public void setIconTintList(ColorStateList tintList) { mExpandDrawable = DrawableCompat.wrap(mExpandDrawable .getConstantState().newDrawable()).mutate(); DrawableCompat.setTintList(mExpandDrawable, tintList); mCollapseDrawable = DrawableCompat.wrap(mCollapseDrawable .getConstantState().newDrawable()).mutate(); DrawableCompat.setTintList(mCollapseDrawable, tintList); super.setIconTintList(tintList); }
Example #24
Source File: RoundedImageView.java From ClipCircleHeadLikeQQ with Apache License 2.0 | 5 votes |
public void setBorderColor(ColorStateList colors) { if (mBorderColor.equals(colors)) { return; } mBorderColor = (colors != null) ? colors : ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR); updateDrawableAttrs(); updateBackgroundDrawableAttrs(false); if (mBorderWidth > 0) { invalidate(); } }
Example #25
Source File: TabLayoutHandler.java From NightOwl with Apache License 2.0 | 5 votes |
@Override public Object[] setup(@NonNull View view, @NonNull TypedArray a, int attr) { TabLayout tabLayout = (TabLayout) view; ColorStateList csl1 = tabLayout.getTabTextColors(); ColorStateList csl2 = a.getColorStateList(attr); return new ColorStateList[]{ csl1, csl2 }; }
Example #26
Source File: TextLayoutBuilder.java From TextLayoutBuilder with Apache License 2.0 | 5 votes |
/** * Sets the text color for the layout. * * @param colorStateList The text color state list for the layout * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setTextColor(ColorStateList colorStateList) { mParams.createNewPaintIfNeeded(); mParams.color = colorStateList; mParams.paint.setColor(mParams.color != null ? mParams.color.getDefaultColor() : Color.BLACK); mSavedLayout = null; return this; }
Example #27
Source File: ComparableGradientDrawable.java From litho with Apache License 2.0 | 5 votes |
@Override public void setStroke(int width, ColorStateList colorStateList, float dashWidth, float dashGap) { super.setStroke(width, colorStateList, dashWidth, dashGap); this.strokeWidth = width; this.strokeDashWidth = dashWidth; this.strokeDashGap = dashGap; this.strokeColorStateList = colorStateList; }
Example #28
Source File: SuntimesUtils.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
public static ColorStateList colorStateList(int onColor, int offColor, int disabledColor, int pressedColor) { return new ColorStateList( new int[][] { new int[] {android.R.attr.state_focused}, new int[] {android.R.attr.state_pressed}, new int[] {-android.R.attr.state_enabled}, new int[] {android.R.attr.state_checked}, new int[] {} }, new int[] {onColor, pressedColor, disabledColor, onColor, offColor} ); }
Example #29
Source File: Coloring.java From actual-number-picker with GNU General Public License v3.0 | 5 votes |
/** * Colors the given drawable to a specified color set using the drawable wrapping technique. * * @param drawable Which drawable to color * @param colorStates Which color set to use * @return A colored drawable ready to use */ public Drawable colorDrawableWrap(Drawable drawable, ColorStateList colorStates) { if (drawable != null) { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTintList(drawable, colorStates); DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_ATOP); drawable = DrawableCompat.unwrap(drawable); return drawable; } return null; }
Example #30
Source File: CustomImageView.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public void setChecked(boolean enable){ if (!enable) { setImageResource(R.drawable.ic_preview_radio_on); setImageTintList(ColorStateList.valueOf(Color.RED)); } else { setImageResource(R.drawable.ic_preview_radio_off); setImageTintList(ColorStateList.valueOf(Color.WHITE)); } }