/// <summary> /// Gets the color of the span. /// </summary> /// <param name="color">The color.</param> /// <param name="defaultColors">The default colors.</param> /// <returns>Android.Graphics.Color.</returns> public Android.Graphics.Color GetSpanColor(Xamarin.Forms.Color color, ColorStateList defaultColors) { if (color == Xamarin.Forms.Color.Default) return new Android.Graphics.Color(defaultColors.DefaultColor); return color.ToAndroid(); }
public static ColorStateList ResolveActionTextColorStateList(Context context, int colorAttr, ColorStateList fallback) { TypedArray a = context.Theme.ObtainStyledAttributes(new int[] { colorAttr }); try { TypedValue value = a.PeekValue(0); if (value == null) { return fallback; } if (value.Type >= DataType.FirstColorInt && value.Type <= DataType.LastColorInt) { return GetActionTextStateList(context, new Color(value.Data)); } else { ColorStateList stateList = a.GetColorStateList(0); if (stateList != null) { return stateList; } else { return fallback; } } } finally { a.Recycle(); } }
private void Initialize (Context context, IAttributeSet attrs) { createNewDraw = context.Resources.GetDrawable (Resource.Drawable.IcAdd); var states = new int[][] { new int[]{ } }; var createNewColor = new int[] {context.Resources.GetColor (Resource.Color.material_green)}; backgroundTintNew = new ColorStateList (states, createNewColor); BackgroundTintList = backgroundTintNew; SetImageDrawable (createNewDraw); }
private void Initialize (Context context, IAttributeSet attrs) { playDraw = context.Resources.GetDrawable (Resource.Drawable.IcPlayArrowWhite); stopDraw = context.Resources.GetDrawable (Resource.Drawable.IcStopWhite); saveDraw = context.Resources.GetDrawable (Resource.Drawable.IcPlayArrowWhite); var states = new int[][] { new int[]{ } }; var playColorArr = new int[] { context.Resources.GetColor (Resource.Color.bright_green)}; var stopColorArr = new int[] { context.Resources.GetColor (Resource.Color.bright_red)}; var saveColorArr = new int[] { context.Resources.GetColor (Resource.Color.gray)}; backgroundTintPlay = new ColorStateList (states, playColorArr); backgroundTintStop = new ColorStateList (states, stopColorArr); backgroundTintSave = new ColorStateList (states, saveColorArr); Switch (playDraw, backgroundTintPlay); }
public static void SetTint(RadioButton radioButton, Color color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-Android.Resource.Attribute.StateChecked}, new int[]{Android.Resource.Attribute.StateChecked}} , new int[]{ DialogUtils.ResolveColor(radioButton.Context,Resource.Attribute.colorControlNormal),color}); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { radioButton.ButtonTintList = sl; } else { Drawable d = ContextCompat.GetDrawable(radioButton.Context, Resource.Drawable.abc_btn_radio_material); DrawableCompat.SetTintList(d, sl); radioButton.SetButtonDrawable(d); } }
private void Update(Color color) { innerPaint.Color = color; outerPaint.Color = color; Drawable selector = CreateSelector(color); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { int[][] states = new int[][]{ new int[]{ Android.Resource.Attribute.StatePressed } }; int[] colors = new int[]{ ShiftColorUp(color) }; ColorStateList rippleColors = new ColorStateList(states, colors); Foreground = new RippleDrawable(rippleColors, selector, null); } else { Foreground = selector; } }
public void SetCellTextColor(ColorStateList colors) { for (int i = 0; i < ChildCount; i++) { ((TextView)GetChildAt(i)).SetTextColor(colors); } }
public LabelRenderer() : base(System.Maui.Maui.Context) { _labelTextColorDefault = TextColors; _visualElementRenderer = new VisualElementRenderer(this); BackgroundManager.Init(this); }
public void SetActiveButton(HamburgerButtons val) { if (_footerView != null) { if (_selectedProfileItem) { if (val == HamburgerButtons.Profile) { return; } _accountHamburgerView.SetBackgroundColor(Color.Transparent); _accountHamburgerView.FindViewById <TextView>(Resource.Id.HamburgerProfileItemLabel).SetTextColor(new Color(ResourceExtension.BrushText)); _selectedProfileItem = false; } if (_selectedSettingsItem) { if (val == HamburgerButtons.Settings) { return; } _settingsHamburgerView.SetBackgroundColor(Color.Transparent); _settingsHamburgerView.FindViewById <TextView>(Resource.Id.HamburgerSettingsItemLabel).SetTextColor(new Color(ResourceExtension.BrushText)); _settingsHamburgerView.FindViewById <ImageView>(Resource.Id.HamburgerSettingsItemIcon).ImageTintList = ColorStateList.ValueOf(new Color(ResourceExtension.BrushText)); _selectedSettingsItem = false; } } long id; switch (val) { case HamburgerButtons.AnimeList: id = (long)PageIndex.PageAnimeList; break; case HamburgerButtons.AnimeSearch: id = (long)PageIndex.PageSearch; break; case HamburgerButtons.LogIn: id = (long)PageIndex.PageLogIn; break; case HamburgerButtons.Settings: if (_settingsHamburgerView != null) { _settingsHamburgerView.SetBackgroundColor(Settings.SelectedTheme == 1 ? new Color(ResourceExtension.BrushAnimeItemBackground) : Color.White); _settingsHamburgerView.FindViewById <TextView>(Resource.Id.HamburgerSettingsItemLabel).SetTextColor(new Color(ResourceExtension.AccentColour)); _settingsHamburgerView.FindViewById <ImageView>(Resource.Id.HamburgerSettingsItemIcon).ImageTintList = ColorStateList.ValueOf(new Color(ResourceExtension.AccentColour)); _selectedSettingsItem = true; } _drawer.SetSelectionAtPosition(-1); return; case HamburgerButtons.Profile: _accountHamburgerView.SetBackgroundColor(Settings.SelectedTheme == 1 ? new Color(ResourceExtension.BrushAnimeItemBackground) : Color.White); _accountHamburgerView.FindViewById <TextView>(Resource.Id.HamburgerProfileItemLabel).SetTextColor(new Color(ResourceExtension.AccentColour)); _selectedProfileItem = true; _drawer.SetSelectionAtPosition(-1); return; case HamburgerButtons.Seasonal: id = (long)PageIndex.PageSeasonal; break; case HamburgerButtons.About: return; case HamburgerButtons.Recommendations: id = (long)PageIndex.PageRecomendations; break; case HamburgerButtons.MangaList: id = (long)PageIndex.PageMangaList; break; case HamburgerButtons.MangaSearch: id = (long)PageIndex.PageSearch; break; case HamburgerButtons.TopAnime: id = (long)PageIndex.PageTopAnime; break; case HamburgerButtons.TopManga: id = (long)PageIndex.PageTopManga; break; case HamburgerButtons.Calendar: id = (long)PageIndex.PageCalendar; break; case HamburgerButtons.Articles: id = (long)PageIndex.PageArticles; break; case HamburgerButtons.News: id = (long)PageIndex.PageArticles; break; case HamburgerButtons.Messanging: _drawer.SetSelectionAtPosition(-1); return; case HamburgerButtons.Forums: id = (long)PageIndex.PageForumIndex; break; case HamburgerButtons.History: id = (long)PageIndex.PageHistory; break; case HamburgerButtons.CharacterSearch: id = (long)PageIndex.PageSearch; break; case HamburgerButtons.Wallpapers: id = (long)PageIndex.PageWallpapers; break; case HamburgerButtons.PopularVideos: id = (long)PageIndex.PagePopularVideos; break; case HamburgerButtons.Feeds: id = (long)PageIndex.PageFeeds; break; case HamburgerButtons.Notifications: _drawer.SetSelectionAtPosition(-1); return; case HamburgerButtons.Clubs: id = (long)PageIndex.PageClubIndex; break; default: throw new ArgumentOutOfRangeException(nameof(val), val, null); } _allowHamburgerNavigation = false; _drawer.SetSelection(id); _allowHamburgerNavigation = true; }
public LabelRenderer() : base(Forms.Context) { _labelTextColorDefault = TextColors; _visualElementRenderer = new VisualElementRenderer(this); }
public void SetTabTextColorListResource(int resId) { TabTextColor = Resources.GetColorStateList(resId); }
public RoundedDrawable SetBorderColor(ColorStateList colors) { _mBorderColor = colors ?? ColorStateList.ValueOf(new Color(0)); _mBorderPaint.Color = new Color(_mBorderColor.GetColorForState(GetState(), Color.Black)); return this; }
public void SetTabTextColor(int textColor) { TabTextColor = GetColorStateList(textColor); }
public HintSpan(string family, TypefaceStyle style, int size, ColorStateList color, ColorStateList linkColor) : base(family, style, size, color, linkColor) { }
public static ColorStateList ToAndroidPreserveDisabled(this Color color, ColorStateList defaults) { int disabled = defaults.GetColorForState(States[1], color.ToAndroid()); return(new ColorStateList(States, new[] { color.ToAndroid().ToArgb(), disabled })); }
private void PrepareMediaDrawable(Button mediaButton) { int[][] states = new int[][] { new int[] {Android.Resource.Attribute.StateSelected }, // disabled new int[] {Android.Resource.Attribute.StatePressed, Android.Resource.Attribute.StateEnabled}, // Pressed new int[] {-Android.Resource.Attribute.StatePressed, Android.Resource.Attribute.StateEnabled}, // not pressed new int[] {-Android.Resource.Attribute.StateEnabled} // disabled }; int[] goTextColors = { Resources.GetColor(Resource.Color.white), Resources.GetColor(Resource.Color.carnation), Resources.GetColor(Resource.Color.carnation), Resources.GetColor(Resource.Color.silver), }; var textColorStateList = new ColorStateList(states, goTextColors); mediaButton.SetTextColor(textColorStateList); mediaButton.RequestLayout(); }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { switch (viewHolder) { case StoryAdapterViewHolder holder: { var item = StoryList[position]; if (item != null) { if (item.Stories?.Count == 1 && item.Stories[0]?.Posted == null) { holder.StoryAvatar.Visibility = ViewStates.Gone; } else { holder.SelfAvartar.Visibility = ViewStates.Gone; } switch (item.Stories?.Count) { case > 0 when item.Stories[0].Thumbnail.Contains("http"): GlideImageLoader.LoadImage(ActivityContext, item.Stories[0]?.Thumbnail, holder.RoundImage, ImageStyle.RoundedCrop, ImagePlaceholders.Drawable); break; case > 0: Glide.With(ActivityContext).Load(new File(item.Stories[0].Thumbnail)).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder).Error(Resource.Drawable.ImagePlacholder)).Into(holder.RoundImage); break; } switch (item.Type) { case "Your": { holder.Circleindicator.Visibility = ViewStates.Gone; YourImageUri = item.Stories[0]?.Thumbnail; GlideImageLoader.LoadImage(ActivityContext, YourImageUri, holder.RoundImage, ImageStyle.RoundedCrop, ImagePlaceholders.Drawable); GlideImageLoader.LoadImage(ActivityContext, YourImageUri, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); break; } case "Live": { holder.Circleindicator.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(AppSettings.MainColor)); GlideImageLoader.LoadImage(ActivityContext, item.Avatar, holder.RoundImage, ImageStyle.RoundedCrop, ImagePlaceholders.Drawable); GlideImageLoader.LoadImage(ActivityContext, item.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); break; } default: item.ProfileIndicator ??= AppSettings.MainColor; holder.Circleindicator.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(item.ProfileIndicator)); // Default_Color GlideImageLoader.LoadImage(ActivityContext, item.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); break; } holder.Name.Text = Methods.FunString.SubStringCutOf(WoWonderTools.GetNameFinal(item), 12); if (item.DataLivePost != null && item.Type == "Live") { holder.VideoStory.Visibility = ViewStates.Visible; } else { holder.VideoStory.Visibility = ViewStates.Gone; } switch (holder.Circleindicator.HasOnClickListeners) { case false: holder.Circleindicator.Click += (sender, e) => Click(new StoryAdapterClickEventArgs { View = holder.MainView, Position = position }); break; } } break; } } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder is UpgradePlansViewHolder holder) { UpgradeGoProClass item = PlansList[position]; if (item != null) { if (AppSettings.SetTabDarkTheme) { holder.MainLayout.SetBackgroundResource(Resource.Drawable.ShadowLinerLayoutDark); holder.RelativeLayout.SetBackgroundResource(Resource.Drawable.price_gopro_item_style_dark); } holder.PlanImg.SetImageResource(item.ImageResource); holder.PlanImg.SetColorFilter(Color.ParseColor(item.HexColor)); var(currency, currencyIcon) = WoWonderTools.GetCurrency(ListUtils.SettingsSiteList?.Currency); Console.WriteLine(currency); if (ListUtils.SettingsSiteList != null) { holder.PriceText.Text = currencyIcon + item.PlanPrice; } else { holder.PriceText.Text = item.PlanPrice; } holder.PlanText.Text = item.PlanText; holder.PerText.Text = item.PlanTime; holder.PlanText.SetTextColor(Color.ParseColor(item.HexColor)); holder.PriceText.SetTextColor(Color.ParseColor(item.HexColor)); holder.UpgradeButton.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(item.HexColor)); Typeface font = Typeface.CreateFromAsset(Application.Context.Resources?.Assets, "ionicons.ttf"); string name = "go_pro_array_" + item.Id; int? resourceId = ActivityContext.Resources?.GetIdentifier(name, "array", ActivityContext.ApplicationInfo.PackageName); if (resourceId == 0) { return; } string[] planArray = ActivityContext.Resources?.GetStringArray(resourceId.Value); if (planArray != null) { foreach (string options in planArray) { if (!string.IsNullOrEmpty(options)) { AppCompatTextView text = new AppCompatTextView(ActivityContext) { Text = options, TextSize = 13 }; text.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.ParseColor("#444444")); text.Gravity = GravityFlags.CenterHorizontal; text.SetTypeface(font, TypefaceStyle.Normal); WoTextDecorator.Content = options; WoTextDecorator.DecoratedContent = new Android.Text.SpannableString(options); WoTextDecorator.SetTextColor(IonIconsFonts.Checkmark, "#43a735"); WoTextDecorator.SetTextColor(IonIconsFonts.Close, "#e13c4c"); LinearLayout.LayoutParams paramsss = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);//height and width are inpixel paramsss.SetMargins(0, 30, 0, 5); text.LayoutParameters = paramsss; holder.OptionLinerLayout.AddView(text); WoTextDecorator.Build(text, WoTextDecorator.DecoratedContent); } } } } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public PagerSlidingTabStrip(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { MyOnGlobalLayoutListner = new MyOnGlobalLayoutListener(this); adapterObserver = new PagerAdapterObserver(this); FillViewport = true; this.VerticalScrollBarEnabled = false; this.HorizontalScrollBarEnabled = false; SetWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.Orientation = Android.Widget.Orientation.Horizontal; tabsContainer.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); AddView(tabsContainer); var dm = Resources.DisplayMetrics; scrollOffset = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, scrollOffset, dm); indicatorHeight = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, indicatorHeight, dm); underlineHeight = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, underlineHeight, dm); dividerPadding = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, dividerPadding, dm); tabPadding = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, tabPadding, dm); dividerWidth = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, dividerWidth, dm); tabTextSize = (int)TypedValue.ApplyDimension(ComplexUnitType.Sp, tabTextSize, dm); //get system attrs (android:textSize and android:textColor) var a = context.ObtainStyledAttributes(attrs, Attrs); tabTextSize = a.GetDimensionPixelSize(TextSizeIndex, tabTextSize); var colorStateList = a.GetColorStateList(TextColorIndex); var textPrimaryColor = a.GetColor(TextColorPrimaryIndex, Android.Resource.Color.White); underlineColor = textPrimaryColor; dividerColor = textPrimaryColor; indicatorColor = textPrimaryColor; int padding = a.GetDimensionPixelSize(PaddingIndex, 0); paddingLeft = padding > 0 ? padding : a.GetDimensionPixelSize(PaddingLeftIndex, 0); paddingRight = padding > 0 ? padding : a.GetDimensionPixelSize(PaddingRightIndex, 0); a = context.ObtainStyledAttributes(attrs, Resource.Styleable.PagerSlidingTabStrip); indicatorColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); dividerWidth = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.GetResourceId(Resource.Styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); isPaddingMiddle = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle); tabTypefaceStyle = (TypefaceStyle)a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextStyle, (int)TypefaceStyle.Bold); tabTypefaceSelectedStyle = (TypefaceStyle)a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, (int)TypefaceStyle.Bold); tabTextColorSelected = a.GetColorStateList(Resource.Styleable.PagerSlidingTabStrip_pstsTextColorSelected); textAlpha = a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextAlpha, textAlpha); a.Recycle(); tabTextColor = colorStateList == null?GetColorStateList(Color.Argb(textAlpha, Color.GetRedComponent(textPrimaryColor), Color.GetGreenComponent(textPrimaryColor), Color.GetBlueComponent(textPrimaryColor))) : colorStateList; tabTextColorSelected = tabTextColorSelected == null?GetColorStateList(textPrimaryColor) : tabTextColorSelected; SetMarginBottomTabContainer(); rectPaint = new Paint(); rectPaint.AntiAlias = true; rectPaint.SetStyle(Paint.Style.Fill); dividerPaint = new Paint(); dividerPaint.AntiAlias = true; dividerPaint.StrokeWidth = dividerWidth; defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 1.0f); }
void UpdateToolbar() { if (_disposed) { return; } Context context = Context; AToolbar bar = _toolbar; ActionBarDrawerToggle toggle = _drawerToggle; if (bar == null) { return; } bool isNavigated = NavigationPageController.StackDepth > 1; bar.NavigationIcon = null; Page currentPage = Element.CurrentPage; if (isNavigated) { if (NavigationPage.GetHasBackButton(currentPage) && !Context.IsDesignerContext()) { if (toggle != null) { toggle.DrawerIndicatorEnabled = false; toggle.SyncState(); } var activity = (AppCompatActivity)context.GetActivity(); var icon = new DrawerArrowDrawable(activity.SupportActionBar.ThemedContext); icon.Progress = 1; bar.NavigationIcon = icon; var prevPage = Element.Peek(1); _defaultNavigationContentDescription = bar.SetNavigationContentDescription(prevPage, _defaultNavigationContentDescription); } else if (toggle != null && _masterDetailPage != null) { toggle.DrawerIndicatorEnabled = _masterDetailPage.ShouldShowToolbarButton(); toggle.SyncState(); } } else { if (toggle != null && _masterDetailPage != null) { toggle.DrawerIndicatorEnabled = _masterDetailPage.ShouldShowToolbarButton(); toggle.SyncState(); } } Color tintColor = Element.BarBackgroundColor; if (Forms.IsLollipopOrNewer) { if (tintColor.IsDefault) { bar.BackgroundTintMode = null; } else { bar.BackgroundTintMode = PorterDuff.Mode.Src; bar.BackgroundTintList = ColorStateList.ValueOf(tintColor.ToAndroid()); } } else { if (tintColor.IsDefault && _backgroundDrawable != null) { bar.SetBackground(_backgroundDrawable); } else if (!tintColor.IsDefault) { if (_backgroundDrawable == null) { _backgroundDrawable = bar.Background; } bar.SetBackgroundColor(tintColor.ToAndroid()); } } Color textColor = Element.BarTextColor; if (!textColor.IsDefault) { bar.SetTitleTextColor(textColor.ToAndroid().ToArgb()); } Color navIconColor = NavigationPage.GetIconColor(Current); if (!navIconColor.IsDefault) { bar.NavigationIcon?.SetColorFilter(navIconColor.ToAndroid(), PorterDuff.Mode.SrcAtop); } bar.Title = currentPage?.Title ?? string.Empty; if (_toolbar.NavigationIcon != null && !textColor.IsDefault) { var icon = _toolbar.NavigationIcon as DrawerArrowDrawable; if (icon != null) { icon.Color = textColor.ToAndroid().ToArgb(); } } UpdateTitleIcon(); UpdateTitleView(); }
public void SetBorderColor(ColorStateList colors) { _borderColor = colors ?? ColorStateList.ValueOf(Color.Black); UpdateDrawableAttrs(); UpdateBackgroundDrawableAttrs(false); if (_borderWidth > 0) { Invalidate(); } }
public TSnackbar SetActionTextColor(ColorStateList colors) { TextView tv = mView.ActionView(); tv.SetTextColor(colors); return this; }
public TextColorSwitcher(ColorStateList textColors) { _defaultTextColors = textColors; }
private void PrepareGoButtonStates() { int[][] states = new int[][] { new int[] {Android.Resource.Attribute.StatePressed, Android.Resource.Attribute.StateEnabled}, // Pressed new int[] {-Android.Resource.Attribute.StatePressed, Android.Resource.Attribute.StateEnabled}, // not pressed new int[] {-Android.Resource.Attribute.StateEnabled} // disabled }; int[] goTextColors = { Resources.GetColor(Resource.Color.silver), Resources.GetColor(Resource.Color.blue2), Resources.GetColor(Resource.Color.silver), }; var textColorStateList = new ColorStateList(states, goTextColors); _goButton.SetTextColor(textColorStateList); }
public void SetTextColorResource(int resId) { TabTextColor = GetColorStateList(Resources.GetColor(resId)); }
private void InitalizeAttributes(IAttributeSet attrs, int defStyle) { TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.PullToRefresharpWrapper, defStyle, 0); header_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_headerId, 0); content_view_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_contentViewId, 0); pulldown_progress_indicator_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_pullDownProgressIndicatorId, 0); pull_to_refresh_string_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_pullToRefreshText, Resource.String.ptrsharp_pull_to_refresh); release_to_refresh_string_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_releaseToRefreshText, Resource.String.ptrsharp_release_to_refresh); refreshing_string_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_refreshingText, Resource.String.ptrsharp_refreshing); header_background_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_ptrHeaderBackground, 0); header_text_color = a.GetColorStateList(Resource.Styleable.PullToRefresharpWrapper_headerTextColor); pulldown_icon_drawable_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_headerIconDrawable, 0); pulldown_tension_factor = a.GetFloat(Resource.Styleable.PullToRefresharpWrapper_pullDownTension, 0.5f); SnapbackDuration = a.GetInt(Resource.Styleable.PullToRefresharpWrapper_snapbackDuration, 400); IsPullEnabled = a.GetBoolean(Resource.Styleable.PullToRefresharpWrapper_pullEnabled, true); fastscroll_thumb_width = a.GetDimensionPixelSize(Resource.Styleable.PullToRefresharpWrapper_fastScrollThumbWidth, -1); if (fastscroll_thumb_width < 0) { fastscroll_thumb_width = Resources.GetDimensionPixelSize(Resource.Dimension.fastscroll_thumb_width); } // Enforce the constraint that both or none of the attributes headerId and viewId are set if (header_res_id > 0 && content_view_res_id == 0 || content_view_res_id > 0 && header_res_id == 0) { throw new ArgumentException("Both headerId and contentViewId must be either set or not set, setting just one is not supported"); } a.Recycle(); }
public void SetTabTextColor(int textColor) { TabTextColor = GetColorStateList (textColor); }
public static ColorStateList ToAndroidPreserveDisabled(this Color color, ColorStateList defaults) { int disabled = defaults.GetColorForState(States[1], color.ToAndroid()); return new ColorStateList(States, new[] { color.ToAndroid().ToArgb(), disabled }); }
public void SetTextColorResource(int resId) { TabTextColor = GetColorStateList(Resources.GetColor (resId)); }
public RoundedImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.RoundedImageView, defStyle, 0); int index = a.GetInt(Resource.Styleable.RoundedImageView_android_scaleType, -1); SetScaleType(index >= 0 ? ScaleTypes[index] : ScaleType.FitCenter); _cornerRadius = a.GetDimensionPixelSize(Resource.Styleable.RoundedImageView_corner_radius, -1); _borderWidth = a.GetDimensionPixelSize(Resource.Styleable.RoundedImageView_border_width, -1); // don't allow negative values for radius and border if (_cornerRadius < 0) { _cornerRadius = DefaultRadius; } if (_borderWidth < 0) { _borderWidth = DefaultBorderWidth; } _borderColor = a.GetColorStateList(Resource.Styleable.RoundedImageView_border_color) ?? ColorStateList.ValueOf(Color.Black); _mutateBackground = a.GetBoolean(Resource.Styleable.RoundedImageView_mutate_background, false); _isOval = a.GetBoolean(Resource.Styleable.RoundedImageView_oval, false); UpdateDrawableAttrs(); UpdateBackgroundDrawableAttrs(true); a.Recycle(); }
public void SetTabTextColorListResource(int resId) { TabTextColor = Resources.GetColorStateList (resId); }
public PagerSlidingTabStrip (Context context, IAttributeSet attrs, int defStyle) : base (context, attrs, defStyle) { MyOnGlobalLayoutListner = new MyOnGlobalLayoutListener (this); adapterObserver = new PagerAdapterObserver (this); FillViewport = true; this.VerticalScrollBarEnabled = false; this.HorizontalScrollBarEnabled = false; SetWillNotDraw(false); tabsContainer = new LinearLayout (context); tabsContainer.Orientation = Android.Widget.Orientation.Horizontal; tabsContainer.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); AddView(tabsContainer); var dm = Resources.DisplayMetrics; scrollOffset = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, scrollOffset, dm); indicatorHeight = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, indicatorHeight, dm); underlineHeight = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, underlineHeight, dm); dividerPadding = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, dividerPadding, dm); tabPadding = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, tabPadding, dm); dividerWidth = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, dividerWidth, dm); tabTextSize = (int)TypedValue.ApplyDimension(ComplexUnitType.Sp, tabTextSize, dm); //get system attrs (android:textSize and android:textColor) var a = context.ObtainStyledAttributes(attrs, Attrs); tabTextSize = a.GetDimensionPixelSize(TextSizeIndex, tabTextSize); var colorStateList = a.GetColorStateList(TextColorIndex); var textPrimaryColor = a.GetColor(TextColorPrimaryIndex, Android.Resource.Color.White); underlineColor = textPrimaryColor; dividerColor = textPrimaryColor; indicatorColor = textPrimaryColor; int padding = a.GetDimensionPixelSize(PaddingIndex, 0); paddingLeft = padding > 0 ? padding : a.GetDimensionPixelSize(PaddingLeftIndex, 0); paddingRight = padding > 0 ? padding : a.GetDimensionPixelSize(PaddingRightIndex, 0); a = context.ObtainStyledAttributes(attrs, Resource.Styleable.PagerSlidingTabStrip); indicatorColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); dividerWidth = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.GetResourceId(Resource.Styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); isPaddingMiddle = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle); tabTypefaceStyle = (TypefaceStyle)a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextStyle, (int)TypefaceStyle.Bold); tabTypefaceSelectedStyle = (TypefaceStyle)a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, (int)TypefaceStyle.Bold); tabTextColorSelected = a.GetColorStateList(Resource.Styleable.PagerSlidingTabStrip_pstsTextColorSelected); textAlpha = a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextAlpha, textAlpha); a.Recycle(); tabTextColor = colorStateList == null ? GetColorStateList(Color.Argb(textAlpha, Color.GetRedComponent(textPrimaryColor), Color.GetGreenComponent(textPrimaryColor), Color.GetBlueComponent(textPrimaryColor))) : colorStateList; tabTextColorSelected = tabTextColorSelected == null ? GetColorStateList(textPrimaryColor) : tabTextColorSelected; SetMarginBottomTabContainer(); rectPaint = new Paint(); rectPaint.AntiAlias = true; rectPaint.SetStyle(Paint.Style.Fill); dividerPaint = new Paint(); dividerPaint.AntiAlias = true; dividerPaint.StrokeWidth = dividerWidth; defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 1.0f); }
public Builder SetPositiveColor(ColorStateList colorStateList) { PositiveColor = colorStateList; PositiveColorSet = true; return this; }
private void setTextColor(ColorStateList color) { if (null != mHeaderText) { mHeaderText.SetTextColor(color); } if (null != mSubHeaderText) { mSubHeaderText.SetTextColor(color); } }
public Builder SetNeutralColor(ColorStateList colorStateList) { NeutralColor = colorStateList; NeutralColorSet = true; return this; }
private void Switch (Drawable src, ColorStateList tint, bool withAnimation = false) { if (!withAnimation) { SetImageDrawable (src); BackgroundTintList = tint; return; } const int ScaleDuration = 200; const int InitialDelay = 100; if (switchAnimation != null) { switchAnimation.Cancel (); switchAnimation = null; } var currentSrc = Drawable; // Scaling down animation var circleAnimOutX = ObjectAnimator.OfFloat (this, "scaleX", 1, 0.1f); var circleAnimOutY = ObjectAnimator.OfFloat (this, "scaleY", 1, 0.1f); circleAnimOutX.SetDuration (ScaleDuration); circleAnimOutY.SetDuration (ScaleDuration); // Alpha out of the icon //var iconAnimOut = ObjectAnimator.OfInt (currentSrc, "alpha", 255, 0); //iconAnimOut.SetDuration (AlphaDuration); var outSet = new AnimatorSet (); outSet.PlayTogether (circleAnimOutX, circleAnimOutY); outSet.SetInterpolator (AnimationUtils.LoadInterpolator (Context, Android.Resource.Animation.AccelerateInterpolator)); outSet.StartDelay = InitialDelay; outSet.AnimationEnd += (sender, e) => { BackgroundTintList = tint; SetImageDrawable (src); JumpDrawablesToCurrentState (); ((Animator)sender).RemoveAllListeners (); }; // Scaling up animation var circleAnimInX = ObjectAnimator.OfFloat (this, "scaleX", 0.1f, 1); var circleAnimInY = ObjectAnimator.OfFloat (this, "scaleY", 0.1f, 1); circleAnimInX.SetDuration (ScaleDuration); circleAnimInY.SetDuration (ScaleDuration); var inSet = new AnimatorSet (); inSet.PlayTogether (circleAnimInX, circleAnimInY); inSet.SetInterpolator (AnimationUtils.LoadInterpolator (Context, Android.Resource.Animation.DecelerateInterpolator)); switchAnimation = new AnimatorSet (); switchAnimation.PlaySequentially (outSet, inSet); switchAnimation.Start (); }
void UpdateBarBackgroundColor() { if (IsDisposed) { return; } if (IsBottomTabPlacement) { Color tintColor = Element.BarBackgroundColor; if (tintColor.IsDefault) { _bottomNavigationView.SetBackground(null); } else if (!tintColor.IsDefault) { _bottomNavigationView.SetBackgroundColor(tintColor.ToAndroid()); } } else { Color tintColor = Element.BarBackgroundColor; if (Forms.IsLollipopOrNewer) { if (tintColor.IsDefault) { _tabLayout.BackgroundTintMode = null; } else { _tabLayout.BackgroundTintMode = PorterDuff.Mode.Src; _tabLayout.BackgroundTintList = ColorStateList.ValueOf(tintColor.ToAndroid()); } } else { if (tintColor.IsDefault && _backgroundDrawable != null) { _tabLayout.SetBackground(_backgroundDrawable); } else if (!tintColor.IsDefault) { // if you don't create a new drawable then SetBackgroundColor // just sets the color on the background drawable that's saved // it doesn't create a new one if (_backgroundDrawable == null && _tabLayout.Background != null) { _backgroundDrawable = _tabLayout.Background; _wrappedBackgroundDrawable = ADrawableCompat.Wrap(_tabLayout.Background).Mutate(); } if (_wrappedBackgroundDrawable != null) { _tabLayout.Background = _wrappedBackgroundDrawable; } _tabLayout.SetBackgroundColor(tintColor.ToAndroid()); } } } }