本文整理汇总了C#中ImageButton.SetImageDrawable方法的典型用法代码示例。如果您正苦于以下问题:C# ImageButton.SetImageDrawable方法的具体用法?C# ImageButton.SetImageDrawable怎么用?C# ImageButton.SetImageDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageButton
的用法示例。
在下文中一共展示了ImageButton.SetImageDrawable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
private void Initialize()
{
_playerName = FindViewById<TextView> (Resource.Id.playerInGameName);
_playerPosition = FindViewById<TextView> (Resource.Id.playerInGamePostion);
_playerScore = FindViewById<TextView> (Resource.Id.playerInGameScore);
_makeThisButton = FindViewById<Button>(Resource.Id.makeThisButton);
_refuseButton = FindViewById<Button>(Resource.Id.refuseButton);
_cardImage = FindViewById<ImageButton>(Resource.Id.taskImageButton);
_actionButton = (TextView)CreateActionButton (Resource.Drawable.table_button);
_points = FindViewById<TextView> (Resource.Id.points);
_x2 = FindViewById<TextView> (Resource.Id.x2);
_taskEnumerator = (TaskEnumerator)Rep.Instance.Tasks.GetEnumerator ();
_playerName.SetTypeface(this.MyriadProFont(MyriadPro.Bold),TypefaceStyle.Normal);
_playerPosition.SetTypeface(this.MyriadProFont(MyriadPro.Regular),TypefaceStyle.Normal);
_makeThisButton.SetTypeface(this.MyriadProFont(MyriadPro.BoldCondensed), TypefaceStyle.Normal);
_refuseButton.SetTypeface(this.MyriadProFont(MyriadPro.BoldCondensed), TypefaceStyle.Normal);
_playerScore.SetTypeface(this.MyriadProFont(MyriadPro.BoldCondensed), TypefaceStyle.Normal);
_points.SetTypeface (this.MyriadProFont (MyriadPro.Bold), TypefaceStyle.Normal);
_x2.SetTypeface (this.MyriadProFont (MyriadPro.Bold), TypefaceStyle.Normal);
_cardImage.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.card_backside));
FindViewById<TextView>(Resource.Id.scoreString).SetTypeface(this.MyriadProFont(MyriadPro.Condensed), TypefaceStyle.Normal);
}
示例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: 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;
}