public void ShowProgress(string message) { if (string.IsNullOrEmpty(message)) { message = "Loading"; } HideProgress(); lock (Locker) { var bound = MainActivity.ScreenSize; var size = Math.Max(bound.Width / 5, 120); _progressAlertDialog = new AlertDialog.Builder(Xamarin.Forms.Forms.Context).Create(); var progressView = CreateProgressView(message, size, bound.Width, bound.Height); var nativeProgressView = ConvertFormsToNative(progressView, new Rectangle(0, 0, bound.Width, bound.Height)); _progressAlertDialog.SetView(nativeProgressView); _progressAlertDialog.SetCanceledOnTouchOutside(false); _progressAlertDialog.SetInverseBackgroundForced(true); Device.BeginInvokeOnMainThread(() => { _progressAlertDialog.Show(); ColorDrawable transparentColor = new ColorDrawable(Android.Graphics.Color.Transparent); _progressAlertDialog.Window.SetBackgroundDrawable(transparentColor); }); } }
public DividerDecoration(int color, int height, int paddingLeft, int paddingRight) { this.mColorDrawable = new ColorDrawable(new Color(color)); this.mHeight = height; this.mPaddingLeft = paddingLeft; this.mPaddingRight = paddingRight; }
protected virtual void SetDialogWindowBGDrawable() { var andColor = _dialogConfig.BackgroundColor.ToAndroid(); var dw = new ColorDrawable(andColor); DWindow.SetBackgroundDrawable(dw); }
BackgroundStateListDrawable(Drawable contentDrawable, AColor averageColor) : base() { // This is a bit tricky... since we are setting up one drawable to be displayed as the background // depending on the cell's current display state, we have to composite the partially transparent // tinting overlay on top of the provided content drawable into a LayerDrawable that we will assign // to the states that the tinting should appear to be applied to. // Get the needed tinting color AColor effectColor = GetEffectColor(averageColor); // Create a new ColorDrawable filled with the tinting color var tint = new ColorDrawable(effectColor); // Create a LayerDrawable that will composite the tint ColorDrawable on top of the provided content // drawable. var compositeContent = new LayerDrawable(new Drawable[] { contentDrawable, tint }); // Assign the composite content to all the states that may be displayed when the user taps the cell AddState(new int[] { Android.Resource.Attribute.StatePressed }, compositeContent); AddState(new int[] { Android.Resource.Attribute.StateFocused }, compositeContent); AddState(new int[] { Android.Resource.Attribute.StateActivated }, compositeContent); // Assign just the passed content drawable for the normal (not tapped) state AddState(new int[] { }, contentDrawable); // Keep a weak reference to the passed content drawable around so we can return it if/when it is needed // later. _contentDrawable = new WeakReference <Drawable>(contentDrawable); }
public DividerDecoration(int color, int height, int paddingLeft, int paddingRight) { _colorDrawable = new ColorDrawable(new Color(color)); _height = height; _paddingLeft = paddingLeft; _paddingRight = paddingRight; }
private RippleDrawable CreateRipple(Color color) { if (Element is Layout) { var mask = new ColorDrawable(Color.White); ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask); return(ripple); } var background = View.Background; if (null == background) { var mask = new ColorDrawable(Color.White); ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask); return(ripple); } if (background is RippleDrawable) { ripple = (RippleDrawable)background.GetConstantState().NewDrawable(); ripple.SetColor(GetPressedColorSelector(color)); return(ripple); } ripple = new RippleDrawable(GetPressedColorSelector(color), background, null); return(ripple); }
public override void OnChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, bool isCurrentlyActive) { try { if (actionState == ItemTouchHelper.ActionStateSwipe) { View itemView = viewHolder.ItemView; Drawable background = new ColorDrawable(); ((ColorDrawable)background).Color = GetBgColorCode(); if (dX > 0) { // swipe right background.SetBounds(itemView.Left, itemView.Top, (int)dX, itemView.Bottom); } else { // swipe left background.SetBounds(itemView.Right + (int)dX, itemView.Top, itemView.Right, itemView.Bottom); } background.Draw(c); } base.OnChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); } catch (Exception e) { Console.WriteLine(e); } }
public object ShowProgress() { var top = Mvx.Resolve <IMvxAndroidCurrentTopActivity>(); var act = top.Activity; View view = act.LayoutInflater.Inflate(Resource.Layout.ProgressView, null); AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.SetCancelable(false); builder.SetView(view); AlertDialog dialog = builder.Create(); dialog.Show(); Window window = dialog.Window; if (window != null) { WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams(); layoutParams.CopyFrom(dialog.Window.Attributes); layoutParams.Width = ViewGroup.LayoutParams.WrapContent; layoutParams.Height = ViewGroup.LayoutParams.WrapContent; dialog.Window.Attributes = layoutParams; Drawable drawable = new ColorDrawable(Android.Graphics.Color.Transparent); dialog.Window.SetBackgroundDrawable(drawable); } return(dialog); }
public override void OnChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, bool isCurrentlyActive) { base.OnChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); var itemView = viewHolder.ItemView; var itemHeight = itemView.Bottom - itemView.Top; // Draw the green edit background var background = new ColorDrawable { Color = Color.ParseColor("#4CAF50") }; background.SetBounds(itemView.Left, itemView.Top, itemView.Left + (int)dX, itemView.Bottom); background.Draw(c); var context = Mvx.IoCProvider.Resolve <IMvxAndroidCurrentTopActivity>().Activity; var editIcon = ContextCompat.GetDrawable(context, Resource.Drawable.baseline_edit_white_24); // Calculate position of edit icon var iconTop = itemView.Top + (itemHeight - editIcon.IntrinsicHeight) / 2; var iconMargin = (itemHeight + editIcon.IntrinsicHeight) / 2; var iconLeft = itemView.Left + iconMargin - editIcon.IntrinsicWidth; var iconRight = itemView.Left + iconMargin; var iconBottom = iconTop + editIcon.IntrinsicHeight; // Draw the edit icon editIcon.SetBounds(iconLeft, iconTop, iconRight, iconBottom); editIcon.Draw(c); }
private void BtnNextTutorialOnClick(object sender, EventArgs e) { try { SaveAppSettings(); SetActive(); AlertDialogSkipTutorial.Hide(); AlertDialogSkipTutorial.Dismiss(); //Open Dialog Finish Tutorial AlertDialogFinishTutorial = new Dialog(Activity, AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base); AlertDialogFinishTutorial.SetContentView(Resource.Layout.DialogFinishTutorial); var backgroundDrawable = new ColorDrawable(Color.Black); backgroundDrawable.SetAlpha(TUTORIAL_DIALOG_BACKGROUND_ALPHA); AlertDialogFinishTutorial.Window.SetBackgroundDrawable(backgroundDrawable); AlertDialogFinishTutorial.Window.SetGravity(GravityFlags.Center); Button btnFinishTutorial = AlertDialogFinishTutorial.FindViewById <Button>(Resource.Id.finishButton); btnFinishTutorial.Click += BtnFinishTutorialOnClick; AlertDialogFinishTutorial.Show(); } catch (Exception exception) { Console.WriteLine(exception); } }
private void SetTransparentBackground(Window window) { var backgroundDrawable = new ColorDrawable(Color.Black); backgroundDrawable.SetAlpha(TUTORIAL_DIALOG_BACKGROUND_ALPHA); window.SetBackgroundDrawable(backgroundDrawable); }
protected virtual void SetColors(Toolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title) { var titleArgb = title.ToAndroid(ShellRenderer.DefaultTitleColor).ToArgb(); if (_titleTextColor != titleArgb) { toolbar.SetTitleTextColor(titleArgb); _titleTextColor = titleArgb; } var newColor = background.ToAndroid(ShellRenderer.DefaultBackgroundColor); if (!(toolbar.Background is ColorDrawable cd) || cd.Color != newColor) { using (var colorDrawable = new ColorDrawable(background.ToAndroid(ShellRenderer.DefaultBackgroundColor))) toolbar.SetBackground(colorDrawable); } var newTintColor = foreground.IsDefault ? ShellRenderer.DefaultForegroundColor : foreground; if (toolbarTracker.TintColor != newTintColor) { toolbarTracker.TintColor = newTintColor; } }
public void UpdateAppearance() { if (!IsEOSCustomizationIgnored) { Background = new ColorDrawable(GetThemeProvider().GetEOSProperty <Color>(this, EOSConstants.NeutralColor6)); } }
private RippleDrawable CreateRipple(Android.Graphics.Color color) { if (Element is Layout) { var mask = new ColorDrawable(Android.Graphics.Color.White); return(_ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask)); } var back = _view.Background; if (back == null) { var mask = new ColorDrawable(Android.Graphics.Color.White); return(_ripple = new RippleDrawable(GetPressedColorSelector(color), null, mask)); } else if (back is RippleDrawable) { _ripple = (RippleDrawable)back.GetConstantState().NewDrawable(); _ripple.SetColor(GetPressedColorSelector(color)); return(_ripple); } else { return(_ripple = new RippleDrawable(GetPressedColorSelector(color), back, null)); } }
private string GetBackgroundColor() { ColorDrawable viewColor = (ColorDrawable)mViewColorSelector.Background; int colorId = viewColor.Color; return(Java.Lang.Integer.ToHexString(colorId).Substring(2).ToUpper()); }
private RippleDrawable CreateRipple(Color color) { if (Element is Xamarin.Forms.Layout) { var mask = new ColorDrawable(Color.White); ripple = new RippleDrawable(GetRippleColorSelector(color), null, mask); return(ripple); } var back = View.Background; if (back == null) { var mask = new ColorDrawable(Color.White); return(ripple = new RippleDrawable(GetRippleColorSelector(color), null, mask)); } if (back is RippleDrawable) { ripple = (RippleDrawable)back.GetConstantState().NewDrawable(); ripple.SetColor(GetRippleColorSelector(color)); return(ripple); } return(ripple = new RippleDrawable(GetRippleColorSelector(color), back, null)); }
void CreateContentView() { var contentView = (_context as FormsAppCompatActivity).LayoutInflater.Inflate(Resource.Layout.CellBaseView, this, true); contentView.LayoutParameters = new ViewGroup.LayoutParams(-1, -1); IconView = contentView.FindViewById <ImageView>(Resource.Id.CellIcon); TitleLabel = contentView.FindViewById <TextView>(Resource.Id.CellTitle); DescriptionLabel = contentView.FindViewById <TextView>(Resource.Id.CellDescription); ContentStack = contentView.FindViewById <LinearLayout>(Resource.Id.CellContentStack); AccessoryStack = contentView.FindViewById <LinearLayout>(Resource.Id.CellAccessoryView); HintLabel = contentView.FindViewById <TextView>(Resource.Id.CellHintText); _backgroundColor = new ColorDrawable(); _selectedColor = new ColorDrawable(Android.Graphics.Color.Argb(125, 180, 180, 180)); var sel = new StateListDrawable(); sel.AddState(new int[] { global::Android.Resource.Attribute.StateSelected }, _selectedColor); sel.AddState(new int[] { -global::Android.Resource.Attribute.StateSelected }, _backgroundColor); sel.SetExitFadeDuration(250); sel.SetEnterFadeDuration(250); Background = sel; _defaultTextColor = new Android.Graphics.Color(TitleLabel.CurrentTextColor); _defaultFontSize = TitleLabel.TextSize; }
public static Drawable CreateItemBackgroundDrawable() { var stateList = ColorStateList.ValueOf(Colors.Black.MultiplyAlpha(0.2f).ToNative()); var colorDrawable = new ColorDrawable(AColor.White); return(new RippleDrawable(stateList, colorDrawable, null)); }
public override void OnChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, bool isCurrentlyActive) { if (actionState == ItemTouchHelper.ActionStateSwipe) { viewHolder.ItemView.TranslationX = dX; if (isCurrentlyActive) { MainActivity.instance.contentRefresh.Enabled = false; } else { MainActivity.instance.contentRefresh.Enabled = true; } ColorDrawable background = new ColorDrawable(Color.Red); if (dX < 0) { background.SetBounds(viewHolder.ItemView.Right + (int)dX, viewHolder.ItemView.Top, viewHolder.ItemView.Right, viewHolder.ItemView.Bottom); drawable.SetBounds(viewHolder.ItemView.Right - MainActivity.instance.DpToPx(52), viewHolder.ItemView.Top + (viewHolder.ItemView.Bottom - viewHolder.ItemView.Top - MainActivity.instance.DpToPx(36)) / 2, viewHolder.ItemView.Right - MainActivity.instance.DpToPx(16), viewHolder.ItemView.Top + (viewHolder.ItemView.Bottom - viewHolder.ItemView.Top + MainActivity.instance.DpToPx(36)) / 2); } else { background.SetBounds(viewHolder.ItemView.Left, viewHolder.ItemView.Top, viewHolder.ItemView.Left + (int)dX, viewHolder.ItemView.Bottom); drawable.SetBounds(viewHolder.ItemView.Left + MainActivity.instance.DpToPx(16), viewHolder.ItemView.Top + (viewHolder.ItemView.Bottom - viewHolder.ItemView.Top - MainActivity.instance.DpToPx(36)) / 2, viewHolder.ItemView.Left + MainActivity.instance.DpToPx(52), viewHolder.ItemView.Top + (viewHolder.ItemView.Bottom - viewHolder.ItemView.Top + MainActivity.instance.DpToPx(36)) / 2); } background.Draw(c); drawable.Draw(c); } else { base.OnChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); } }
protected override void OnCreate(Bundle bundle) { MobileBarcodeScanner.Initialize(Application); base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); ActionBar.Hide(); var color = new ColorDrawable(new Color(0, 0, 0, 3)); ImageButton buttonQR = FindViewById <ImageButton>(Resource.Id.btnScannerQR); buttonQR.Click += delegate { StartActivity(typeof(ScannerActivity)); }; ImageButton buttonLts = FindViewById <ImageButton>(Resource.Id.btnList); buttonLts.Click += delegate { StartActivity(typeof(ListRegistroActivity)); }; }
private void DrawBackground(Canvas c, RectF rect) { using (var colorDrawable = new ColorDrawable(BackgroundColor)) { colorDrawable.SetBounds((int)rect.Left, (int)rect.Top, (int)rect.Right, (int)rect.Bottom); colorDrawable.Draw(c); } }
/// <summary> /// gets the color that was chosen from the color picker /// </summary> /// <param name="requestCode">the view to change</param> /// <param name="resultCode">the result code - ok/cancled</param> /// <param name="data">the data that was sent in an intent</param> protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == BALL_REQUEST_CODE) { if (resultCode == Result.Ok) { if (!data.Extras.IsEmpty) { int color = data.GetIntExtra(Constants.COLOR, 0); //get the color int that was chosen ColorDrawable colorDrawable = new ColorDrawable(ColorManager.Instance.IntToColorConvertor(color)); btnBallColor.Background = colorDrawable; //set the button color to it ColorManager.Instance.SetColor(ColorKey.Ball, color); //update the color in the color manager } } } if (requestCode == BAT_REQUEST_CODE) { if (resultCode == Result.Ok) { if (!data.Extras.IsEmpty) { int color = data.GetIntExtra(Constants.COLOR, 0); ColorDrawable colorDrawable = new ColorDrawable(ColorManager.Instance.IntToColorConvertor(color)); btnBatColor.Background = colorDrawable; ColorManager.Instance.SetColor(ColorKey.Bat, color); } } } if (requestCode == BRICK_REQUEST_CODE) { if (resultCode == Result.Ok) { if (!data.Extras.IsEmpty) { int color = data.GetIntExtra(Constants.COLOR, 0); ColorDrawable colorDrawable = new ColorDrawable(ColorManager.Instance.IntToColorConvertor(color)); btnBrickColor.Background = colorDrawable; ColorManager.Instance.SetColor(ColorKey.Brick, color); } } } if (requestCode == BACKGROUND_REQUEST_CODE) { if (resultCode == Result.Ok) { if (!data.Extras.IsEmpty) { int color = data.GetIntExtra(Constants.COLOR, 0); ColorDrawable colorDrawable = new ColorDrawable(ColorManager.Instance.IntToColorConvertor(color)); btnBackgroundColor.Background = colorDrawable; ColorManager.Instance.SetColor(ColorKey.Background, color); Recreate(); } } } }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var colorDrawable = new ColorDrawable(Color.DeepSkyBlue); Activity.ActionBar.SetBackgroundDrawable(colorDrawable); _adapter = new FileListAdapter(Activity, new FileSystemInfo[0]); ListAdapter = _adapter; }
protected virtual void SetColors(Toolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title) { var titleArgb = title.ToAndroid(ShellRenderer.DefaultTitleColor).ToArgb(); toolbar.SetTitleTextColor(titleArgb); using (var colorDrawable = new ColorDrawable(background.ToAndroid(ShellRenderer.DefaultBackgroundColor))) toolbar.SetBackground(colorDrawable); toolbarTracker.TintColor = foreground.IsDefault ? ShellRenderer.DefaultForegroundColor : foreground; }
protected override void OnWindowVisibilityChanged(Android.Views.ViewStates visibility) { base.OnWindowVisibilityChanged(visibility); var actionBar = activity.ActionBar; var colorDrawable = new ColorDrawable(Android.Graphics.Color.Red); actionBar.SetStackedBackgroundDrawable(colorDrawable); ActionBarTabsSetup(actionBar); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var colorDrawable = new ColorDrawable(Color.DeepSkyBlue); ActionBar.SetBackgroundDrawable(colorDrawable); SetTheme(Android.Resource.Style.ThemeMaterialLight); SetContentView(Resource.Layout.ConnectionsSettings); }
public static RippleDrawable CreateRipple(Android.Graphics.Color color, Drawable background = null) { if (background == null) { var mask = new ColorDrawable(Android.Graphics.Color.White); return(new RippleDrawable(GetPressedColorSelector(color), null, mask)); } return(new RippleDrawable(GetPressedColorSelector(color), background, null)); }
public SwipeToDelete_v2(RecyclerView.Adapter adapter, Context context) { mAdapter = (MyAdapter)adapter; mContext = context; background = new ColorDrawable(); deleteDrawable = context.GetDrawable(Resource.Drawable.ic_delete); intrinsicWidth = deleteDrawable.IntrinsicWidth; intrinsicHeight = deleteDrawable.IntrinsicHeight; }
protected virtual void SetColors(TabLayout tabLayout, Color foreground, Color background, Color title, Color unselected) { var titleArgb = title.ToAndroid(ShellRenderer.DefaultTitleColor).ToArgb(); var unselectedArgb = unselected.ToAndroid(ShellRenderer.DefaultUnselectedColor).ToArgb(); tabLayout.SetTabTextColors(unselectedArgb, titleArgb); using (var colorDrawable = new ColorDrawable(background.ToAndroid(ShellRenderer.DefaultBackgroundColor))) tabLayout.SetBackground(colorDrawable); tabLayout.SetSelectedTabIndicatorColor(foreground.ToAndroid(ShellRenderer.DefaultForegroundColor)); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var colorDrawable = new ColorDrawable(Color.DeepSkyBlue); ActionBar.SetBackgroundDrawable(colorDrawable); client = new TCP_Client(this); SetContentView(Resource.Layout.Main); Button syncProfileMenu_btn = FindViewById <Button>(Resource.Id.profileMenu); syncProfileMenu_btn.Click += (sender, e) => { var intent = new Intent(this, typeof(ProfilesMenuActivity)); StartActivity(intent); }; Button netSettings_btn = FindViewById <Button>(Resource.Id.connectionMenu); netSettings_btn.Click += (sender, e) => CreateNetSettingsDialog(); Button startSync_btn = FindViewById <Button>(Resource.Id.startSync); startSync_btn.Click += (sender, e) => { try { if (SyncProfilesHandler.SelectedProfilesList != null) { foreach (var profile in SyncProfilesHandler.SelectedProfilesList) { //Toast.MakeText(this, "profile #" + idx.ToString(), ToastLength.Short).Show(); profileProcessor = new ProfileProcessor(TCP_Client.SSLStream); profileProcessor.ProcessingProfile(profile); Toast.MakeText(this, profile.ProfileName, ToastLength.Short).Show(); Toast.MakeText(this, AppData.Message1, ToastLength.Short).Show(); Toast.MakeText(this, AppData.Message2, ToastLength.Short).Show(); } } } catch (System.Exception) { throw; } }; Button devInfo_dtn = FindViewById <Button>(Resource.Id.button3); devInfo_dtn.Click += (sender, e) => { var intent = new Intent(this, typeof(ConflictResolveActivity)); StartActivity(intent); }; }
public Attributes(Context context) { _mContext = context; Background = new ColorDrawable(Color.Transparent); CancelButtonBackground = new ColorDrawable(Color.Black); ColorDrawable gray = new ColorDrawable(Color.Gray); OtherButtonTopBackground = gray; OtherButtonMiddleBackground = gray; OtherButtonBottomBackground = gray; OtherButtonSingleBackground = gray; CancelButtonTextColor = Color.White; OtherButtonTextColor = Color.Black; Padding = Dp2Px(20); OtherButtonSpacing = Dp2Px(2); CancelButtonMarginTop = Dp2Px(10); ActionSheetTextSize = Dp2Px(16); }