Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 对齐文本视图';设置左、右、上、下值后的文本_C#_Android_Xamarin_Xamarin.android_Textview - Fatal编程技术网

C# 对齐文本视图';设置左、右、上、下值后的文本

C# 对齐文本视图';设置左、右、上、下值后的文本,c#,android,xamarin,xamarin.android,textview,C#,Android,Xamarin,Xamarin.android,Textview,我正在以编程方式设置文本视图的左、右、顶部、底部属性,该属性位于其同级的OnLayout方法中,它应该位于同级的顶部。但是,在我设置了这些属性之后,文本没有在中心对齐。它似乎是水平对齐,但不是垂直对齐 我已尝试设置TextView的Gravity以及TextAlignment的 protected override void OnLayout(bool changed, int left, int top, int right, int bottom) {

我正在以编程方式设置
文本视图的
顶部
底部
属性,该属性位于其同级的
OnLayout
方法中,它应该位于同级的顶部。但是,在我设置了这些属性之后,文本没有在中心对齐。它似乎是水平对齐,但不是垂直对齐

我已尝试设置
TextView
Gravity
以及
TextAlignment

protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            _labelTextView = new TextView(Context)
            {
                Background = ContextCompat.GetDrawable(Context, 
                Resource.Drawable.blue_circle),
                Text = "N/A",
                Gravity = GravityFlags.Center,
                TextAlignment = TextAlignment.Center,
            };

            _labelTextView.Left = left;
            _labelTextView.Top = top + 20;
            _labelTextView.Bottom = bottom - 50;
            _labelTextView.Right = right;

            base.OnLayout(changed, left, top, right, bottom);
        }

需要的是
\u labelTextView.Measure(0,0)

i、 e


需要的是
\u labelTextView.Measure(0,0)

i、 e

_labelTextView.Left = left;
_labelTextView.Top = top + 20;
_labelTextView.Bottom = bottom - 50;
_labelTextView.Right = right;

_labelTextView.Measure(0, 0);