public override bool OnPrepareOptionsMenu(IMenu menu) { //InvalidateOptionsMenu(); menu.GetItem(0).SetIcon(_favorite ? ContextCompat.GetDrawable(this, PlanYourJourney.Resource.Drawable.ic_action_star) : ContextCompat.GetDrawable(this, PlanYourJourney.Resource.Drawable.ic_action_star_border)); return(base.OnPrepareOptionsMenu(menu)); }
private BitmapDrawable GetDrawable(string imageEntryImage) { int resID = Resources.GetIdentifier(imageEntryImage, "drawable", this.Context.PackageName); var drawable = ContextCompat.GetDrawable(this.Context, resID); var bitmap = ((BitmapDrawable)drawable).Bitmap; return(new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, element.ImageWidth * 2, element.ImageHeight * 2, true))); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); if (Control != null) { Control.Background = ContextCompat.GetDrawable(Context, Resource.Drawable.search_bar); } }
public void StyleView() { searchResultList.SetLayoutManager(new LinearLayoutManager(this.Context)); var dividerItemDecoration = new DividerItemDecoration(searchResultList.Context, DividerItemDecoration.Vertical); dividerItemDecoration.SetDrawable(ContextCompat.GetDrawable(this.Context, Resource.Drawable.line_devider)); searchResultList.AddItemDecoration(dividerItemDecoration); }
private BitmapDrawable GetDrawable(string imageEntryImage) { int resID = Resources.GetIdentifier(System.IO.Path.GetFileNameWithoutExtension(imageEntryImage), "drawable", this.Context.PackageName); var drawable = ContextCompat.GetDrawable(this.Context, resID); var bitmap = ((BitmapDrawable)drawable).Bitmap; return(new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, element.ImageWidth, element.ImageHeight, true))); }
private BitmapDrawable GetDrawable(string name, int width, int height) { int resID = Resources.GetIdentifier(name, "drawable", Context.PackageName); var drawable = ContextCompat.GetDrawable(Context, resID); var bitmap = ((BitmapDrawable)drawable).Bitmap; return(new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, width, height, false))); }
private VectorDrawable GetDrawable(string imagePath) { int resID = Resources.GetIdentifier(imagePath, "drawable", this.Context.PackageName); var drawable = ContextCompat.GetDrawable(this.Context, resID); var bitmap = ((VectorDrawable)drawable); return(bitmap); }
public ItemTouchHelperCallback(IItemTouchHelperAdapter adapter) { mAdapter = adapter; deleteIcon = ContextCompat.GetDrawable(App.Context, Resource.Drawable.ic_delete_white_24dp); deleteBackground = new ColorDrawable(new Color(ContextCompat.GetColor(App.Context, Resource.Color.bg_swipe_delete))); iconMargin = (int)App.Context.Resources.GetDimension(Resource.Dimension.delete_icon_margin); }
private BitmapDrawable GetDrawable(string image) { int resourceID = Resources.GetIdentifier(image, "drawable", this.Context.PackageName); Drawable drawable = ContextCompat.GetDrawable(this.Context, resourceID); Bitmap bitmap = (drawable as BitmapDrawable).Bitmap; return(new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, customEntry.ImageWidth, customEntry.ImageHeight, true))); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = ContextCompat.GetDrawable(Forms.Context, Resource.Drawable.leftbutton); } }
private void Init() { /*var resources = _context.Resources; * _resizeDrawableWidth = resources.GetDrawable(Resource.Drawable.camera_crop_width); * _resizeDrawableHeight = resources.GetDrawable(Resource.Drawable.camera_crop_height);*/ _resizeDrawableWidth = ContextCompat.GetDrawable(CrossCurrentActivity.Current.Activity, Resource.Drawable.camera_crop_width); _resizeDrawableHeight = ContextCompat.GetDrawable(CrossCurrentActivity.Current.Activity, Resource.Drawable.camera_crop_height); }
StateListDrawable GetBackgroundImageList() { var backgroundImageState = new StateListDrawable(); backgroundImageState.AddState(new int[] { global::Android.Resource.Attribute.StateChecked }, ContextCompat.GetDrawable(this.Context, Resource.Drawable.celsius)); backgroundImageState.AddState(new int[] { }, ContextCompat.GetDrawable(this.Context, Resource.Drawable.fahrenheit)); return(backgroundImageState); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); this.shadow = FindViewById <Com.Yinglan.Shadowimageview.ShadowImageView>(Resource.Id.shadow); this.seekBar = FindViewById <AppCompatSeekBar>(Resource.Id.seekbar); shadow.Click += (sender, args) => { int res = Resource.Mipmap.lotus; switch (resId) { case 1: res = Resource.Mipmap.mountain; resId = 2; break; case 2: res = Resource.Mipmap.sunset; resId = 3; break; case 3: res = Resource.Mipmap.red; resId = 4; break; case 4: res = Resource.Mipmap.lotus; resId = 1; break; } if (resId == 1 || resId == 3) { shadow.SetImageResource(res); } else { shadow.SetImageDrawable(ContextCompat.GetDrawable(this, res)); } }; seekBar.ProgressChanged += (sender, args) => { shadow.SetImageRadius(args.Progress); }; LoadNetImage(); }
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { var icon = _iconSource.List.ElementAt(position); var holder = (IconListHolder)viewHolder; var drawable = ContextCompat.GetDrawable(_context, icon.Value); holder.Icon.SetImageDrawable(drawable); }
/// <summary> /// Sets the menu icon and badge. /// </summary> /// <param name="backArrow">if set to <c>true</c> [back arrow].</param> /// <param name="fromBackgroundService">if set to <c>true</c> [from background service].</param> public void SetMenuIconAndBadge(bool backArrow = false, bool fromBackgroundService = false) { if (backArrow) { RunOnUiThread(() => _toolbar.NavigationIcon = ContextCompat.GetDrawable(this, Resource.Drawable.ic_arrow_back)); return; } RunOnUiThread(() => _toolbar.NavigationIcon = ContextCompat.GetDrawable(this, Resource.Drawable.menu)); }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (Control != null) { Control.StateListAnimator = null; Control.Background = ContextCompat.GetDrawable(Context, Resource.Drawable.login_button_selector); } }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { var hold = holder as MyViewHolder; hold.ImageView.SetImageDrawable(ContextCompat.GetDrawable(itemView.Context, categories[position].Icon)); hold.TextView.Text = categories[position].Name; hold.Layout.SetBackgroundColor(Color.ParseColor(CatColor)); hold.Layout.LayoutParameters.Width = Fragment.P.X / 3; }
public void OnPageSelected(int position) { for (int i = 0; i < imagesList.Count; i++) { dots[i].SetImageDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.unselectedDot)); } dots[position].SetImageDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.selectedDot)); }
public DrawerAroundAdapter(Context context) { this.context = context; this.manager = FavoriteManager.Obtain(context); this.starDrawable = DrawableCompat.Wrap(ContextCompat.GetDrawable(context, Resource.Drawable.ic_small_star)); DrawableCompat.SetTint(starDrawable, ContextCompat.GetColor(context, Resource.Color.white_tint_secondary)); this.favorites = new HashSet <Int32> (); LoadFavorites(); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control != null) { Control.SetBackground(ContextCompat.GetDrawable(Context, Android.Resource.Color.Transparent)); } }
private void Init() { findBtn = ContextCompat.GetDrawable(this.Context, Resource.Drawable.ic_search); findBtn.SetBounds(0, 0, findBtn.IntrinsicWidth, findBtn.IntrinsicHeight); this.SetSingleLine(true); this.CompoundDrawablePadding = 20; this.SetPadding(this.PaddingStart, this.PaddingTop, 20, this.PaddingBottom); this.SetCompoundDrawables(this.GetCompoundDrawables()[0], this.GetCompoundDrawables()[1], findBtn, this.GetCompoundDrawables()[3]); }
private void ImageTooLargeWarning() { Toast.MakeText(this, "Fotografie prea mare! Dimensiunea maxima acceptata este de 10 Mb.", ToastLength.Long).Show(); var resourcePath = "@drawable/profile"; // where myresource (without the extension) is the file int imageResource = Resources.GetIdentifier(resourcePath, null, PackageName); Drawable res = ContextCompat.GetDrawable(this, imageResource); ciwProfileImage.SetImageDrawable(res); }
private void FullscreenDialog() { mainpage.RemoveView(PlayerView); ((Activity)Context).RequestedOrientation = Android.Content.PM.ScreenOrientation.SensorLandscape; mFullScreenDialog.AddContentView(PlayerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); mFullScreen.SetImageDrawable(ContextCompat.GetDrawable(Context, Resource.Drawable.exo_controls_fullscreen_exit)); mExoPlayerFullscreen = true; mFullScreenDialog.Show(); }
private void closeFullscreenDialog() { ((ViewGroup)PlayerView.Parent).RemoveView(PlayerView); mainpage.AddView(PlayerView); ((Activity)Context).RequestedOrientation = Android.Content.PM.ScreenOrientation.SensorPortrait; mFullScreen.SetImageDrawable(ContextCompat.GetDrawable(Context, Resource.Drawable.exo_controls_fullscreen_enter)); mExoPlayerFullscreen = false; mFullScreenDialog.Dismiss(); }
public LayerDrawable AddPickerStyles(string imagePath) { Drawable border = ContextCompat.GetDrawable(this.Context, Resource.Drawable.roundedBorder); Drawable[] layers = { border, GetDrawable(imagePath) }; LayerDrawable layerDrawable = new LayerDrawable(layers); layerDrawable.SetLayerInset(0, 0, 0, 0, 0); return(layerDrawable); }
private BitmapDrawable GetDrawable(string imageEntryImage, int imageHeight, int imageWidth) { var resId = (int)typeof(Resource.Drawable) .GetField(imageEntryImage.Replace(".jpg", "").Replace(".png", "")).GetValue(null); var drawable = ContextCompat.GetDrawable(this.Context, resId); var bitmap = ((BitmapDrawable)drawable).Bitmap; return(new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, (int)(imageWidth * 2 * _ratio), (int)(imageHeight * 2 * _ratio), true))); }
private BitmapDrawable GetDrawable() { int resID = Resources.GetIdentifier("calendar", "drawable", this.Context.PackageName); var drawable = ContextCompat.GetDrawable(this.Context, resID); var bitmap = ((BitmapDrawable)drawable).Bitmap; var result = new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, 20, 20, true)); result.Gravity = Android.Views.GravityFlags.Right; return(result); }
public void OnPageSelected(int position) { var context = Activity.ApplicationContext; for (var i = 0; i < _dotsCount; i++) { _dotsImage[i].SetImageDrawable(ContextCompat.GetDrawable(context, NonActd)); } _dotsImage[position].SetImageDrawable(ContextCompat.GetDrawable(context, ActiveD)); }
public DefaultFooter(Activity context) { MainContext = context; animationLoading = new AnimationDrawable(); foreach (var src in loadingAnimSrcs) { animationLoading.AddFrame(ContextCompat.GetDrawable(context, src), 150); animationLoading.OneShot = (false); } }
private BitmapDrawable GetDrawable(string imageEntryImage) { int resID = Resources.GetIdentifier(imageEntryImage, "drawable", this.Context.PackageName); var drawable = ContextCompat.GetDrawable(this.Context, resID); var bitmap = ((BitmapDrawable)drawable).Bitmap; var resultHeight = drawable.IntrinsicHeight / 2; var resultWidth = drawable.IntrinsicWidth / 2; return(new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, resultWidth, resultHeight, true))); }