当前位置: 首页>>代码示例>>C#>>正文


C# ImageView.SetScaleType方法代码示例

本文整理汇总了C#中ImageView.SetScaleType方法的典型用法代码示例。如果您正苦于以下问题:C# ImageView.SetScaleType方法的具体用法?C# ImageView.SetScaleType怎么用?C# ImageView.SetScaleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageView的用法示例。


在下文中一共展示了ImageView.SetScaleType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetView

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ImageView imageView = new ImageView(mContext);
            imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
            imageView.LayoutParameters = (new GridView.LayoutParams(250, 250));

            if (Categories[position].Picture != null)
            {
                var webClient = new WebClient();
                webClient.DownloadDataCompleted += (s, e) =>
                {
                    try
                    {
                        var bytes = e.Result; // get the downloaded data
                        
                        imageView.SetImageBitmap(ImageHandler.BytesToImage(bytes));  // convert the data to an actual image
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Something went wrong loading image for cell..." + ex.Message);
                    }

                };
                webClient.DownloadDataAsync(new Uri(Categories[position].Picture));
            }

            return imageView;
        }
开发者ID:dsb92,项目名称:patientcare,代码行数:28,代码来源:CategoryAdapter.cs

示例2: IndicatorLayout

        public IndicatorLayout(Context context, Mode mode)

            : base(context)
        {
            //super(context);
            mArrowImageView = new ImageView(context);

            Drawable arrowD = Resources.GetDrawable(Resource.Drawable.indicator_arrow);
            mArrowImageView.SetImageDrawable(arrowD);

            int padding = Resources.GetDimensionPixelSize(Resource.Dimension.indicator_internal_padding);
            mArrowImageView.SetPadding(padding, padding, padding, padding);
            AddView(mArrowImageView);

            int inAnimResId, outAnimResId;
            switch (mode)
            {
                case Mode.PULL_FROM_END:
                    inAnimResId = Resource.Animation.slide_in_from_bottom;
                    outAnimResId = Resource.Animation.slide_out_to_bottom;
                    SetBackgroundResource(Resource.Drawable.indicator_bg_bottom);

                    // Rotate Arrow so it's pointing the correct way
                    mArrowImageView.SetScaleType(Android.Widget.ImageView.ScaleType.Matrix);
                    Matrix matrix = new Matrix();

                    matrix.SetRotate(180f, arrowD.IntrinsicWidth / 2f, arrowD.IntrinsicHeight / 2f);
                    mArrowImageView.ImageMatrix = matrix;
                    break;
                default:
                case Mode.PULL_FROM_START:
                    inAnimResId = Resource.Animation.slide_in_from_top;
                    outAnimResId = Resource.Animation.slide_out_to_top;
                    SetBackgroundResource(Resource.Drawable.indicator_bg_top);
                    break;
            }

            mInAnim = AnimationUtils.LoadAnimation(context, inAnimResId);
            mInAnim.SetAnimationListener(this);

            mOutAnim = AnimationUtils.LoadAnimation(context, outAnimResId);
            mOutAnim.SetAnimationListener(this);

            IInterpolator interpolator = new LinearInterpolator();

            //mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
            mRotateAnimation = new RotateAnimation(0, -180, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f);


            mRotateAnimation.Interpolator = interpolator;
            mRotateAnimation.Duration = DEFAULT_ROTATION_ANIMATION_DURATION;
            mRotateAnimation.FillAfter = true;

            mResetRotateAnimation = new RotateAnimation(-180, 0, Dimension.RelativeToSelf, 0.5f,
                    Dimension.RelativeToSelf, 0.5f);
            mResetRotateAnimation.Interpolator = interpolator;
            mResetRotateAnimation.Duration = DEFAULT_ROTATION_ANIMATION_DURATION;
            mResetRotateAnimation.FillAfter = true;

        }
开发者ID:skywolf888,项目名称:Android-PullToRefresh.Net,代码行数:60,代码来源:IndicatorLayout.cs

示例3: OnCreate

        protected override void OnCreate(Bundle savedInstanceState) {
            base.OnCreate(savedInstanceState);
            
            var pos = 0;
            if (Intent.Extras != null)
                pos = Intent.Extras.GetInt("pos");

            var birds = Resources.GetStringArray(Resource.Array.birds);
            var imgs = Resources.ObtainTypedArray(Resource.Array.birds_img);
            var resId = imgs.GetResourceId(pos, -1);

            Title = birds[pos];
            Window.RequestFeature(WindowFeatures.ActionBarOverlay);
            var color = new ColorDrawable(Color.Black);
            color.SetAlpha(128);
            ActionBar.SetBackgroundDrawable(color);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            _handler = new Handler();

            var imageView = new ImageView(this);
            imageView.SetScaleType(ImageView.ScaleType.CenterInside);
            imageView.SetImageResource(resId);
            imageView.Click += (sender, args) =>
                {
                    ActionBar.Show();
                    HideActionBarDelayed(_handler);
                };
            SetContentView(imageView);
            Window.SetBackgroundDrawableResource(Android.Resource.Color.BackgroundDark);
        }
开发者ID:mamta-bisht,项目名称:SlidingMenuSharp,代码行数:30,代码来源:BirdActivity.cs

示例4: SetSource

 private async void SetSource(ImageView img, string src) {
     var bm = await this.Source.GetBitmap(src);
     if (bm != null) {
         img.SetImageBitmap(bm);
         img.SetScaleType(ImageView.ScaleType.FitXy);
         bm.Dispose();
     }
 }
开发者ID:gruan01,项目名称:Xamarin-Example,代码行数:8,代码来源:FlipViewAdapter.cs

示例5: InstantiateItem

        public override Object InstantiateItem(ViewGroup container, int position)
        {
            imageView = new ImageView(container.Context);
            imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
            imageLoader.DisplayImage(Urls[position], imageView);
            container.AddView(imageView);

            return imageView;
        }
开发者ID:Ontropix,项目名称:xatropix,代码行数:9,代码来源:SimpleCarouselAdapter.cs

示例6: GetView

            // create a new ImageView for each item referenced by the Adapter
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                ImageView i = new ImageView(context);

                i.SetImageResource(thumbIds[position]);
                i.LayoutParameters = new Gallery.LayoutParams(240, 160);
                i.SetScaleType(ImageView.ScaleType.FitXy);

                return i;
            }
开发者ID:BitStab,项目名称:monodroid-samples,代码行数:11,代码来源:GalleryScreen.cs

示例7: GetView

        // create a new ImageView for each item referenced by the Adapter
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var i = new ImageView(_context);

            i.SetImageResource(_thumbIds[position]);
            i.LayoutParameters = new Android.Widget.Gallery.LayoutParams(350, 300);
            i.SetScaleType(ImageView.ScaleType.FitXy);

            return i;
        }
开发者ID:RealAikido,项目名称:MobileSamples,代码行数:11,代码来源:ImageAdapter.cs

示例8: InstantiateItem

 public override Java.Lang.Object InstantiateItem(View container, int position)
 {
     ImageView imageView = new ImageView(context);
     imageView.SetScaleType(ImageView.ScaleType.CenterInside);
     Picasso.With(Android.App.Application.Context)
            .Load(images[position])
                 .Transform(new CropSquareTransformation())
                 .Into(imageView);
     ((ViewPager)container).AddView(imageView, 0);
     return imageView;
 }
开发者ID:takigava,项目名称:pikabu,代码行数:11,代码来源:ImageAdapter.cs

示例9: NewView

        public override View NewView(Context context, ICursor cursor, ViewGroup parent)
        {
            var grid = (GridView)parent;

            var imageView = new ImageView(context);
            imageView.LayoutParameters = new GridView.LayoutParams(grid.ColumnWidth, grid.ColumnWidth);
            imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
            imageView.SetPadding(8, 8, 8, 8);

            return imageView;
        }
开发者ID:adbk,项目名称:spikes,代码行数:11,代码来源:ImageAdapter.cs

示例10: MakeView

        public View MakeView()
        {
            ImageView imageView = new ImageView(this.ApplicationContext);
            imageView.SetScaleType(ImageView.ScaleType.FitCenter);

            ViewGroup.LayoutParams params2 = new ImageSwitcher.LayoutParams(
                WindowManagerLayoutParams.MatchParent, WindowManagerLayoutParams.MatchParent);

            imageView.LayoutParameters=params2;
            return imageView;
        }
开发者ID:pejmrivas,项目名称:sycket,代码行数:11,代码来源:ticketActivity.cs

示例11: NewView

        public override View NewView(Context context, ICursor cursor, ViewGroup parent)
        {
            var gv = parent as GridView;

            int px = Utils.GetPixFromGridView(context, parent as GridView);
            px = gv.ColumnWidth;

            var imageView = new ImageView(context);
            imageView.LayoutParameters = new GridView.LayoutParams(px, px);
            imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
            imageView.SetPadding(8, 8, 8, 8);

            return imageView;
        }
开发者ID:adbk,项目名称:spikes,代码行数:14,代码来源:ImageAdapter.cs

示例12: GetView

        // create a new ImageView for each item referenced by the Adapter
        public override View GetView(int position, View convertView, ViewGroup parent)
        {

            ImageView iHold = new ImageView(context);
            //make sure we don't get an index out of bounds exception
            if (imageUrls.Count > position)
            {
                string pic = imageUrls[position];
                var bit = bitmaps.Where(x => x.Id == pic).FirstOrDefault();
                if (!String.IsNullOrEmpty(pic))
                {
                    if (bit == null)
                    {
                        Task<bool>.Factory.StartNew(
                                       () =>
                                       {
                                           try
                                           {
                                               LoggerMobile.Instance.logMessage("downloading:" + pic, LoggerEnum.message);
                                               var i = Image.GetImageBitmapFromUrl(pic);
                                               Image img = new Image();
                                               img.Id = pic;
                                               img.Img = i;
                                               if (i != null)
                                               {
                                                   bitmaps.Add(img);
                                                   context.RunOnUiThread(() =>
                                                   {
                                                       iHold.SetImageBitmap(i);

                                                       iHold.LayoutParameters = new Gallery.LayoutParams(300, 300);
                                                       iHold.SetScaleType(ImageView.ScaleType.FitXy);
                                                   });
                                               }
                                           }
                                           catch (Exception exception)
                                           {
                                               ErrorHandler.Save(exception, MobileTypeEnum.Android, context);
                                           }
                                           return true;
                                       });
                    }
                    else
                        iHold.SetImageBitmap(bit.Img);
                }
            }

            return iHold;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:50,代码来源:ImageAdapter.cs

示例13: GetArtworkView

        private View GetArtworkView(int position, Uri uri, View convertView)
        {
            var imageView = new ImageView(Application.Context);

            imageView.LayoutParameters = new GridView.LayoutParams (100, 100);
            imageView.SetScaleType (ImageView.ScaleType.FitXy);

            ThreadPool.QueueUserWorkItem(a => 
                { 
                    DownloadBitmap(uri.AbsoluteUri);
                    RunOnUiThread(() => imageView.SetImageBitmap (BitmapCache.Get(uri.AbsoluteUri)));
                });

            return imageView;
        }
开发者ID:crswlls,项目名称:packdrop,代码行数:15,代码来源:ArtworkPreviewActivity.cs

示例14: GetView

		public override Android.Views.View GetView (int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
		{
			ImageView imageView;

			if (convertView == null) {  // if it's not recycled, initialize some attributes
				imageView = new ImageView (context);
				imageView.LayoutParameters = new GridView.LayoutParams (120, 120);
				imageView.SetScaleType (ImageView.ScaleType.CenterCrop);
				imageView.SetPadding (8, 8, 8, 8);
			} else {
				imageView = (ImageView)convertView;
			}

			imageView.SetImageResource (thumbIds [position]);
			return imageView;
		}
开发者ID:andreicoroama,项目名称:android_whist,代码行数:16,代码来源:ImageAdapter.cs

示例15: GetView

			public override View GetView (int position, View convertView, ViewGroup parent)
			{
				ImageView i;

				if (convertView == null) {
					i = new ImageView (self);
					i.SetScaleType (ImageView.ScaleType.FitCenter);
					i.LayoutParameters = new GridView.LayoutParams (50, 50);
				} else {
					i = (ImageView) convertView;
				}

				ResolveInfo info = ((Grid1)self).mApps[position];
				i.SetImageDrawable (info.ActivityInfo.LoadIcon (self.PackageManager));

				return i;
			}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:17,代码来源:Grid1.cs


注:本文中的ImageView.SetScaleType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。