本文整理汇总了C#中Button.SetCompoundDrawablesWithIntrinsicBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetCompoundDrawablesWithIntrinsicBounds方法的具体用法?C# Button.SetCompoundDrawablesWithIntrinsicBounds怎么用?C# Button.SetCompoundDrawablesWithIntrinsicBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.SetCompoundDrawablesWithIntrinsicBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateButton
private Button GenerateButton(MenuItem item)
{
Button btn = new Button (_context);
btn.Text = item.Text;
var param = new TableLayout.LayoutParams (0, LayoutParams.WrapContent, 1f);
if (margin >= 0) {
marginBottom = marginLeft = marginTop = marginRight = margin;
}
param.BottomMargin = MarginBottom;
param.LeftMargin = MarginLeft;
param.TopMargin = MarginTop;
param.RightMargin = MarginRight;
btn.LayoutParameters = param;
if (item.IconId != 0) {
btn.SetCompoundDrawablesWithIntrinsicBounds (null,
Resources.GetDrawable (item.IconId),
null, null);
}
btn.SetTypeface (tabTypeface, typefaceStyle);
btn.SetTextColor (TextColor);
btn.TextSize = TextSize;
btn.SetBackgroundColor (ItemBgColor);
btn.SetBackgroundResource (ItemBg);
if (padding != 0) {
paddingLeft = paddingTop = paddingRight = paddingBottom = padding;
}
btn.SetPadding (paddingLeft, paddingTop, paddingRight, paddingBottom);
btn.Click += (o, e) => {
if (ItemClicked != null) {
ItemClicked (this, item.ItemId);
}
};
return btn;
}
示例2: PopulateBinaries
void PopulateBinaries()
{
ViewGroup binariesGroup = (ViewGroup)FindViewById(Resource.Id.binaries);
binariesGroup.RemoveAllViews();
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);
foreach (KeyValuePair<string, ProtectedBinary> pair in State.Entry.Binaries.OrderBy(p => p.Key) )
{
String key = pair.Key;
String label = key;
if ((String.IsNullOrEmpty(label) || (!App.Kp2a.GetDb().DatabaseFormat.SupportsAttachmentKeys)))
{
label = "<attachment>";
}
Button binaryButton = new Button(this) {Text = label};
binaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuDelete),null, null, null);
binaryButton.Click += (sender, e) =>
{
State.EntryModified = true;
State.Entry.Binaries.Remove(key);
PopulateBinaries();
};
binariesGroup.AddView(binaryButton,layoutParams);
}
Button addBinaryButton = new Button(this) {Text = GetString(Resource.String.add_binary)};
addBinaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuAdd) , null, null, null);
addBinaryButton.Enabled = true;
if (!App.Kp2a.GetDb().DatabaseFormat.CanHaveMultipleAttachments)
addBinaryButton.Enabled = !State.Entry.Binaries.Any();
addBinaryButton.Click += (sender, e) =>
{
Util.ShowBrowseDialog(this, Intents.RequestCodeFileBrowseForBinary, false, false);
};
binariesGroup.AddView(addBinaryButton,layoutParams);
var binariesLabel = FindViewById(Resource.Id.entry_binaries_label);
if (binariesLabel != null)
binariesLabel.Visibility = State.Entry.Binaries.UCount > 0 ? ViewStates.Visible : ViewStates.Gone;
}