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


C# Button.SetCompoundDrawablesWithIntrinsicBounds方法代码示例

本文整理汇总了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;
        }
开发者ID:Nininea,项目名称:ForwardNavigationMenu,代码行数:37,代码来源:ForwardNavigationMenu.cs

示例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;
        }
开发者ID:pythe,项目名称:wristpass,代码行数:43,代码来源:EntryEditActivity.cs


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