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


C# ImageButton.SetScaleType方法代码示例

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


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

示例1: GetSampleContent

        public override Android.Views.View GetSampleContent(Context context)
        {
            sfGrid = new SfDataGrid(context);
            viewModel = new ExportingViewModel();
            sfGrid.AutoGeneratingColumn += GridGenerateColumns;
            sfGrid.ItemsSource = (viewModel.OrdersInfo);
            exportPdf = new ImageButton(context);
            exportPdf.SetMaxHeight(30);
            exportPdf.SetMaxWidth(30);
            exportPdf.SetBackgroundColor(Android.Graphics.Color.Transparent); 
            exportPdf.SetImageResource(Resource.Drawable.pdfexport);
            exportPdf.SetScaleType(ImageView.ScaleType.FitXy);
            exportPdf.LayoutParameters = new ViewGroup.LayoutParams( 120,120);
            exportPdf.Click += ExportToPdf;
            exportExcel = new ImageButton(context);
            exportExcel.SetMaxHeight(30);
            exportExcel.SetMaxWidth(30);
            exportExcel.SetBackgroundColor(Android.Graphics.Color.Transparent);
            exportExcel.SetImageResource(Resource.Drawable.excelexport);
            exportExcel.SetScaleType(ImageView.ScaleType.FitXy);
            exportExcel.LayoutParameters = new ViewGroup.LayoutParams(120, 120);
            exportExcel.Click += ExportToExcel;

            LinearLayout option = new LinearLayout(context);
            option.SetGravity(GravityFlags.Center);
            option.Orientation = Android.Widget.Orientation.Horizontal;
            var pdftext = new TextView(context) { Text = "Export to Pdf" };
            pdftext.SetTypeface(null, TypefaceStyle.Bold);
            var exceltext = new TextView(context) { Text = "Export to Excel" };
            exceltext.SetTypeface(null, TypefaceStyle.Bold);
            option.AddView(exportPdf);         
            option.AddView(pdftext);
            option.AddView(exportExcel);
            option.AddView(exceltext);
            
            LinearLayout mainView = new LinearLayout(context);
            mainView.Orientation = Android.Widget.Orientation.Vertical;
            mainView.AddView(option);
            mainView.AddView(sfGrid);
            return mainView;
        }
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:41,代码来源:Exporting.cs

示例2: AddActionButtonCompatFromMenuItem

		// Adds an action button to the compatibility action bar, using menu information from a
		// MenuItem. If the menu item ID is menu_refresh, the menu item's state
		// can be changed to show a loading spinner using
		// ActivityHelper#setRefreshActionButtonCompatState(boolean).
		private View AddActionButtonCompatFromMenuItem (IMenuItem item)
		{
			var action_bar = GetActionBarCompat ();

			if (action_bar == null)
				return null;

			// Create the separator
			var separator = new ImageView (activity, null, Resource.Attribute.actionbarCompatSeparatorStyle);
			separator.LayoutParameters = new ViewGroup.LayoutParams (2, ViewGroup.LayoutParams.FillParent);

			// Create the button
			var action_button = new ImageButton (activity, null, Resource.Attribute.actionbarCompatButtonStyle);
			action_button.LayoutParameters = new ViewGroup.LayoutParams ((int)activity.Resources.GetDimension (Resource.Dimension.actionbar_compat_height), ViewGroup.LayoutParams.FillParent);

			action_button.SetImageDrawable (item.Icon);
			action_button.SetScaleType (ImageView.ScaleType.Center);
			action_button.ContentDescriptionFormatted = item.TitleFormatted;
			action_button.Click += delegate {
				activity.OnMenuItemSelected ((int)WindowFeatures.OptionsPanel, item); };

			action_bar.AddView (separator);
			action_bar.AddView (action_button);

			if (item.ItemId == Resource.Id.menu_refresh) {
				// Refresh buttons should be stateful, and allow
				//  for indeterminate progress indicators,so add those.
				var width = activity.Resources.GetDimensionPixelSize (Resource.Dimension.actionbar_compat_height);
				width = width / 3;

				var indicator = new ProgressBar (activity, null, Resource.Attribute.actionbarCompatProgressIndicatorStyle);

				var layout = new LinearLayout.LayoutParams (width, width);
				layout.SetMargins (width, width, (width * 3) - 2 * width, 0);

				indicator.LayoutParameters = layout;
				indicator.Visibility = ViewStates.Gone;
				indicator.Id = Resource.Id.menu_refresh_progress;

				action_bar.AddView (indicator);
			}

			return action_button;
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:48,代码来源:ActivityHelper.cs

示例3: AddActionButtonCompat

		private View AddActionButtonCompat (int iconResId, int textResId, EventHandler clickAction, bool separatorAfter)
		{
			var action_bar = GetActionBarCompat ();

			if (action_bar == null)
				return null;

			// Create the separator
			var separator = new ImageView (activity, null, Resource.Attribute.actionbarCompatSeparatorStyle);
			separator.LayoutParameters = new ViewGroup.LayoutParams (2, ViewGroup.LayoutParams.FillParent);

			// Create the button
			var action_button = new ImageButton (activity, null, Resource.Attribute.actionbarCompatButtonStyle);
			action_button.LayoutParameters = new ViewGroup.LayoutParams ((int)activity.Resources.GetDimension (Resource.Dimension.actionbar_compat_height), ViewGroup.LayoutParams.FillParent);

			action_button.SetImageResource (iconResId);
			action_button.SetScaleType (ImageView.ScaleType.Center);
			action_button.ContentDescription = activity.Resources.GetString (textResId);
			action_button.Click += clickAction;

			// Add separator and button to the action bar in the desired order
			if (!separatorAfter)
				action_bar.AddView (separator);

			action_bar.AddView (action_button);

			if (separatorAfter)
				action_bar.AddView (separator);

			return action_button;
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:31,代码来源:ActivityHelper.cs

示例4: addActionItemCompatFromMenuItem

        /**
         * Adds an action button to the compatibility action bar, using menu information from a {@link
         * android.view.IMenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's
         * state can be changed to show a loading spinner using
         * {@link com.example.android.actionbarcompat.ActionBarHelperBase#setRefreshActionItemState(bool)}.
         */
        private View addActionItemCompatFromMenuItem(IMenuItem item)
        {
            int itemId = item.ItemId;

            ViewGroup actionBar = getActionBarCompat();
            if (actionBar == null) {
                return null;
            }

            // Create the button
            ImageButton actionButton = new ImageButton(mActivity, null,
                    itemId == Resource.Id.home
                            ? Resource.attr.actionbarCompatItemHomeStyle
                            : Resource.attr.actionbarCompatItemStyle);
            actionButton.LayoutParameters = (new ViewGroup.LayoutParams(
                    (int) mActivity.getResources().getDimension(
                            itemId == android.Resource.Id.home
                                    ? Resource.dimen.actionbar_compat_button_home_width
                                    : Resource.dimen.actionbar_compat_button_width),
                    ViewGroup.LayoutParams.FILL_PARENT));
            if (itemId == Resource.Id.menuSync) {
                actionButton.Id = Resource.Id.actionbar_compat_item_refresh;
            }
            actionButton.SetImageDrawable(item.Icon);
            actionButton.SetScaleType(ImageView.ScaleType.Center);
            actionButton.ContentDescription = item.TitleFormatted;
            //	        actionButton.setOnClickListener(new View.OnClickListener() {
            //	            public void onClick(View view) {
            //	                mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
            //	            }
            //	        });

            actionBar.AddView(actionButton);

            if (item.ItemId == Resource.Id.menuSync) {
                // Refresh buttons should be stateful, and allow for indeterminate progress indicators,
                // so add those.
                ProgressBar indicator = new ProgressBar(mActivity, null,
                        Resource.attr.actionbarCompatProgressIndicatorStyle);

                int buttonWidth = mActivity.Resources.GetDimensionPixelSize(
                        Resource.dimen.actionbar_compat_button_width);
                int buttonHeight = mActivity.Resources.GetDimensionPixelSize(
                        Resource.dimen.actionbar_compat_height);
                int progressIndicatorWidth = buttonWidth / 2;

                LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(
                        progressIndicatorWidth, progressIndicatorWidth);
                indicatorLayoutParams.SetMargins(
                        (buttonWidth - progressIndicatorWidth) / 2,
                        (buttonHeight - progressIndicatorWidth) / 2,
                        (buttonWidth - progressIndicatorWidth) / 2,
                        0);
                indicator.LayoutParameters = indicatorLayoutParams;
                indicator.Visibility = ViewStates.Gone;
                indicator.Id = Resource.Id.actionbar_compat_item_refresh_progress;
                actionBar.AddView(indicator);
            }

            return actionButton;
        }
开发者ID:decriptor,项目名称:tomdroid,代码行数:67,代码来源:ActionBarHelperBase.cs

示例5: GetPasswordAsync

 public Task<string> GetPasswordAsync(Stream keypadImageStream, IList<MapAreaInfo> mapAreas, SiteManager site)
 {
     var tcs = new TaskCompletionSource<string>();
     var adb = new AlertDialog.Builder(Context);
     using (var inflater = LayoutInflater.From(adb.Context))
     {
         var view = inflater.Inflate(Resource.Layout.XjtuCardPassword, null);
         var passwordView = view.FindViewById<TextView>(Resource.Id.passwordTextView);
         var padTable = view.FindViewById<TableLayout>(Resource.Id.passwordPadTable);
         var currentPassword = "";
         Action updatePasswordDisplay = () =>
         {
             passwordView.Text = new string('#', currentPassword.Length);
         };
         //生成按键。
         var keypadBitmap = BitmapFactory.DecodeStream(keypadImageStream);
         for (var row = 0; row < 4; row++)
         {
             var tr = new TableRow(adb.Context)
             {
                 LayoutParameters = new ViewGroup.LayoutParams(
                     ViewGroup.LayoutParams.WrapContent,
                     ViewGroup.LayoutParams.WrapContent)
             };
             padTable.AddView(tr);
             for (var col = 0; col < 3; col++)
             {
                 var index = row * 3 + col;
                 var indexExpr = Convert.ToString(index);
                 View buttonView = null;
                 if (index <= 9)
                 {
                     var area = mapAreas.First(a => a.Value == indexExpr);
                     var button = new ImageButton(adb.Context)
                     {
                         LayoutParameters = new TableRow.LayoutParams(
                             ViewGroup.LayoutParams.WrapContent,
                             ViewGroup.LayoutParams.WrapContent),
                     };
                     button.SetMinimumWidth(DroidUtility.DipToPixelsX(64));
                     button.SetMinimumHeight(DroidUtility.DipToPixelsY(64));
                     button.SetImageBitmap(Bitmap.CreateBitmap(keypadBitmap, area.X1, area.Y1, area.Width, area.Height));
                     button.SetScaleType(ImageView.ScaleType.FitCenter);
                     button.Click += (_, e) =>
                     {
                         currentPassword += indexExpr;
                         updatePasswordDisplay();
                     };
                     buttonView = button;
                 } else if (index == 10)
                 {
                     var button = new Button(adb.Context)
                     {
                         Text = "更正",
                         LayoutParameters = new TableRow.LayoutParams(
                             ViewGroup.LayoutParams.MatchParent,
                             ViewGroup.LayoutParams.WrapContent)
                         {
                             Span = 2,
                             Gravity = GravityFlags.CenterVertical
                         }
                     };
                     button.Click += (_, e) =>
                     {
                         currentPassword = "";
                         updatePasswordDisplay();
                     };
                     buttonView = button;
                 }
                 if (buttonView != null)
                 {
                     tr.AddView(buttonView);
                 }
             }
         }
         //初始化界面。
         updatePasswordDisplay();
         adb.SetView(view)
             .SetPositiveButton("确定", (_, e) =>
             {
                 tcs.SetResult(currentPassword);
             })
             .SetNegativeButton("取消", (_, e) =>
             {
                 tcs.SetResult(null);
             })
             .Show();
     }
     return tcs.Task;
 }
开发者ID:CXuesong,项目名称:App2,代码行数:90,代码来源:ManualVerificationProvider.cs


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