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


C# Button.SetPadding方法代码示例

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


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

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.Conversations);

            ImageView btns = FindViewById<ImageView> (Resource.Id.imgNewUserHeader);
            TextView header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader);
            RelativeLayout relLayout = FindViewById<RelativeLayout> (Resource.Id.relativeLayout1);
            ImageHelper.setupTopPanel (btns, header, relLayout, header.Context);
            context = header.Context;
            Header.headertext = Application.Context.Resources.GetString (Resource.String.converseMainTitle);
            Header.fontsize = 36f;
            ImageHelper.fontSizeInfo (header.Context);
            header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
            header.Text = Header.headertext;

            isMe = AndroidData.CurrentUser.FirstName + " " + AndroidData.CurrentUser.LastName;
            mmg = wowZapp.LaffOutOut.Singleton.mmg;
            dbm = wowZapp.LaffOutOut.Singleton.dbm;
            contentPackItems = new Dictionary<int,ContentPackItem> ();
            voiceFiles = new Dictionary<int,string> ();
            pollingSteps = new Dictionary<int,PollingStep> ();
            contacts = new Dictionary<Guid,ContactDB> ();

            mmg.MessageSendConfirmCompleted += MessageManager_MessageSendConfirmCompleted;
            wowZapp.LaffOutOut.Singleton.ReceivedMessages += AppDelegate_ReceivedMessages;

            ImageButton btnAdd = FindViewById<ImageButton> (Resource.Id.btnAdd);
            btnAdd.Tag = 2;
            ImageButton btnHome = FindViewById<ImageButton> (Resource.Id.btnHome);
            btnHome.Tag = 1;
            ImageButton btnBack = FindViewById<ImageButton> (Resource.Id.btnBack);
            btnBack.Tag = 0;
            LinearLayout bottom = FindViewById<LinearLayout> (Resource.Id.bottomHolder);
            ImageButton[] buttons = new ImageButton[3];
            buttons [0] = btnBack;
            buttons [1] = btnHome;
            buttons [2] = btnAdd;
            ImageHelper.setupButtonsPosition (buttons, bottom, context);

            if (ConversationsUtil.userFrom != null) {
                UserDB lastFrom = ConversationInfo.GetSenderOfOldestMessage ();
                if (lastFrom == null)
                    lastFrom = ConversationInfo.GetAllConversationParticipants () [0];
                Header.headertext = ConversationInfo.GetConversationPartipantsNameTitle ();
                Header.fontsize = 36f;
                ImageHelper.fontSizeInfo (header.Context);
                header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
                header.Text = Header.headertext;
                LinearLayout ll4 = FindViewById<LinearLayout> (Resource.Id.linearLayout4);
                btnAdd.Visibility = ViewStates.Invisible;
                btnBack.Visibility = ViewStates.Invisible;
                Button btnAll = new Button (context);
                Rect rect = new Rect ();
                btnHome.GetDrawingRect (rect);
                int xLeft = rect.Left;
                int yTop = rect.Top;
                btnAll.Visibility = ViewStates.Invisible;
                btnAll.SetWidth (400);
                btnAll.SetHeight (200);
                btnAll.Gravity = GravityFlags.CenterVertical;
                btnAll.Layout (xLeft, yTop, 400, 200);
                btnAll.SetPadding (30, 20, 30, 20);
                btnAll.SetTextColor (Color.Black);
                btnAll.Text = Application.Context.Resources.GetString (Resource.String.converseShowAllBtn);
                btnAll.Click += new EventHandler (btnAll_Click);
                ll4.AddView (btnAll);
                ll4.Invalidate ();
            }

            RunOnUiThread (delegate {
                contacts = dbm.GetAllContactsForOwner (AndroidData.CurrentUser.AccountID.ToString ()).ToDictionary (s => s.ContactAccountID, s => s);
                GetMessageRows ();
            });
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:75,代码来源:ConversationActivity.cs

示例2: OnActivityResult

        /* Snippet 2 Ende */
        /// <summary>
        /// Aufgenommenes Foto durch Project Oxford analysieren lassen und das Ergebnis visualisieren
        /// </summary>
        /// <param name="requestCode"></param>
        /// <param name="resultCode"></param>
        /// <param name="data"></param>
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            var progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar1);
            try
            {
                // User canceled
                if (resultCode == Result.Canceled)
                    return;

                MediaFile file = await data.GetMediaFileExtraAsync(this);

                //Alte Face-Rectangles entfernen
                var rellayout = FindViewById<RelativeLayout>(Resource.Id.relativeLayout1);
                for (int i = 2; i < rellayout.ChildCount; i++)
                {
                    rellayout.RemoveViewAt(i);
                }
                
                progressBar.Visibility = ViewStates.Visible;

                //Foto in ImageView anzeigen
                var bmp = BitmapFactory.DecodeFile(file.Path);
                ImageView _imgView = FindViewById<ImageView>(Resource.Id.imageView1);
                _imgView.SetImageBitmap(bmp);

                //Bild Analyse durch Project Oxford
                await _vm.Load(file.GetStream());

                //Brechnen der Face Rectangle Positionen
                float scale;
                if (_imgView.Width / bmp.Width >= _imgView.Height / bmp.Height)
                {
                    scale = (float)bmp.Height / _imgView.Height;
                }
                else
                {
                    scale = (float)bmp.Width / _imgView.Width;
                }

                var relX = (_imgView.Width - bmp.Width / scale) / 2;
                var relY = (_imgView.Height - bmp.Height / scale) / 2;
                foreach (Emotion.Contract.Emotion emo in _vm.Emotions)
                {
                    //Zeichnen der Face Rectangles
                    var butt = new Button(this);
                    GradientDrawable drawable = new GradientDrawable();
                    drawable.SetShape(ShapeType.Rectangle);
                    drawable.SetStroke(5, Color.Rgb(34, 135, 202));
                    drawable.SetColor(Color.Transparent);
                    butt.Background = drawable;
                    var layoutparams = new RelativeLayout.LayoutParams((int)Math.Ceiling(emo.FaceRectangle.Width / scale), (int)Math.Ceiling(emo.FaceRectangle.Height / scale));
                    layoutparams.SetMargins((int)Math.Ceiling(emo.FaceRectangle.Left / scale + relX), (int)Math.Ceiling(emo.FaceRectangle.Top / scale + relY), 0, 0);

                    butt.LayoutParameters = layoutparams;
                    butt.SetPadding(0, 0, 0, 0);
                    butt.Click += (e, s) =>
                    {
                        //Bei Klick auf Face Rectangle Emotionswerte anzeigen
                        (FindViewById<ProgressBar>(Resource.Id.angerProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Anger * 100);
                        (FindViewById<ProgressBar>(Resource.Id.contemptProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Contempt * 100);
                        (FindViewById<ProgressBar>(Resource.Id.disgustProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Disgust * 100);
                        (FindViewById<ProgressBar>(Resource.Id.fearProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Fear * 100);
                        (FindViewById<ProgressBar>(Resource.Id.happinessProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Happiness * 100);
                        (FindViewById<ProgressBar>(Resource.Id.neutralProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Neutral * 100);
                        (FindViewById<ProgressBar>(Resource.Id.sadnessProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Sadness * 100);
                        (FindViewById<ProgressBar>(Resource.Id.surpriseProgressBar)).Progress = (int)Math.Ceiling(emo.Scores.Surprise * 100);
                    };
                    rellayout.AddView(butt);
                }
            }
            finally{ progressBar.Visibility = ViewStates.Invisible; }
        }
开发者ID:maltegoetz,项目名称:EmotionDetector,代码行数:80,代码来源:MainActivity.cs

示例3: 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

示例4: GetSampleContent

		public override View GetSampleContent (Context context)
		{
			btn = new Button(context);
			btn.SetBackgroundResource(Resource.Drawable.burgericon);
			FrameLayout.LayoutParams btlayoutParams = new FrameLayout.LayoutParams(42,32, GravityFlags.Center);

			btn.LayoutParameters = btlayoutParams;
			btn.SetPadding (10,0,0,0);
			btn.Gravity=GravityFlags.CenterVertical;


			TextView textView = new TextView(context);
			textView.TextSize=20;
			textView.Text="Home";
			textView.SetTextColor (Color.White);
			textView.Gravity=GravityFlags.Center;
			LinearLayout linearLayout =  new LinearLayout(context);
			FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 70, GravityFlags.Center);
			layoutParams.SetMargins (10,0,0,0);
			linearLayout.SetPadding (10,0,0,0);
			linearLayout.AddView(btn);linearLayout.AddView(textView,layoutParams);
			linearLayout.SetBackgroundColor(Color.Rgb(47,173,227));



			height = context.Resources.DisplayMetrics.HeightPixels-75;
			width =context.Resources.DisplayMetrics.WidthPixels;

			LinearLayout linear2 = new LinearLayout(context);
			linear2.Orientation=Orientation.Vertical;
			linear2.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
			FrameLayout.LayoutParams layout2= new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, GravityFlags.Center);
			linear2.AddView(linearLayout,layout2);

			/**
			 * Main Content
			 * */




			FrameLayout gridLayout = new FrameLayout(context);
			gridLayout.LayoutParameters=new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

			/**
         * item1
         */

			FrameLayout grid1 = new FrameLayout(context);
			ImageView img1 = new ImageView(context);
			img1.SetScaleType (ImageView.ScaleType.FitXy);
			img1.SetImageResource(Resource.Drawable.profile);

			FrameLayout.LayoutParams layoutParams1 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, GravityFlags.Center);

			grid1.AddView(img1, layoutParams1);

			grid1.LayoutParameters=new ViewGroup.LayoutParams((width-20) / 2,(height - 100)/3);

			/**
         * item2
         */

			FrameLayout grid2 = new FrameLayout(context);
			ImageView img2 = new ImageView(context);
			img2.SetImageResource(Resource.Drawable.inbox);
			img2.SetScaleType (ImageView.ScaleType.FitXy);
			grid2.AddView(img2, layoutParams1);
			grid2.LayoutParameters=new ViewGroup.LayoutParams((width-20) / 2,(height - 100)/3);

			/**
         * item3
         */

			FrameLayout grid3 = new FrameLayout(context);
			ImageView img3 = new ImageView(context);
			img3.SetImageResource(Resource.Drawable.outbox);
			img3.SetScaleType (ImageView.ScaleType.FitXy);
			grid3.AddView(img3, layoutParams1);
			grid3.LayoutParameters=new ViewGroup.LayoutParams((width-20) / 2,(height - 100)/3);


			/**
         * item4
         */

			FrameLayout grid4 = new FrameLayout(context);
			ImageView img4 = new ImageView(context);
			img4.SetImageResource(Resource.Drawable.flag);
			img4.SetScaleType (ImageView.ScaleType.FitXy);
			grid4.AddView(img4, layoutParams1);
			grid4.LayoutParameters=new ViewGroup.LayoutParams((width-20) / 2,(height - 100)/3);
			/**
         * item5
         */
			FrameLayout grid5 = new FrameLayout(context);
			ImageView img5 = new ImageView(context);
			img5.SetImageResource(Resource.Drawable.trash);
			img5.SetScaleType (ImageView.ScaleType.FitXy);

//.........这里部分代码省略.........
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:101,代码来源:NavigationDrawer.cs


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