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


C# TextView.Layout方法代码示例

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


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

示例1: NoteRepresentation

        /// <summary>
        /// Constructs a new representation as a visual ball with a number of string in its center.
        /// </summary>
        /// <param name="currentActivity">The activity on which the ball should be drawn.</param>
        /// <param name="note">The note that should be played correspondingly when visually arriving to the guitar's neck.</param>
        public NoteRepresentation(Activity currentActivity, Note note)
        {
            //Basic values.
            _currentActivity = currentActivity;
            _note = note;

            //The color of the ball.
            BallColor ballColor = (BallColor)note.Position.String; //note.Position.Fret;
            //Which string the number on the ball should represent.
            //GuitarString stringNum = note.Position.String;

            _noteCircle = new TextView(_currentActivity);

            //Select the ball's color.
            switch (ballColor)
            {
                case BallColor.Red:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_red);
                    break;
                case BallColor.Purple:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_purple);
                    break;
                case BallColor.Blue:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_blue);
                    break;
                case BallColor.Green:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_green);
                    break;
                case BallColor.Orange:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_orange);
                    break;
                case BallColor.Aqua:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_aqua);
                    break;
                case BallColor.Yellow:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_yellow);
                    break;
            }

            //Set dimensions.
            _noteCircle.Layout(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
            //Center text.
            _noteCircle.Gravity = GravityFlags.Center;
            //Set text.
            //_noteCircle.SetText(((int)stringNum).ToString(), TextView.BufferType.Normal);
            //Refresh view.
            _noteCircle.RequestLayout();

            //Add the newly created note circle to the current activity.
            _currentActivity.AddContentView(_noteCircle, new ViewGroup.LayoutParams(BUTTON_WIDTH, BUTTON_HEIGHT));
        }
开发者ID:sagisprojects,项目名称:Virtual-Guitar-Teacher,代码行数:56,代码来源:NoteRepresentation.cs


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