本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}