使用Visual Studio 2017社区版,我试图使用C#在文本视图中居中旋转的文本。 (我提到了Visual Studio版本,因为一些较旧的问题对我没有帮助,因为这个版本拒绝它作为无效语法。)
这是层次结构:
(LinearLayout)tmrowInner --- --->(LinearLayout)的父级ll --- ---的父级> (TextView)tv
在我的代码的其他地方:
tmrowInner.SetGravity(GravityFlags.End);
我已经尝试了所有许多建议的值来代替"结束"但无济于事。
这是代码(在for循环中更改变量dateindex):
timetoenter = CurrentTimeSlot.ToString("hh:mm tt");
LinearLayout ll = FindViewById<LinearLayout>(tmrowInnerId);
LinearLayout llInner = new LinearLayout(this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
llInner.SetBackgroundColor(Android.Graphics.Color.Pink);
llInner.Orientation = Orientation.Vertical;
lp.Height = height +40;
lp.Width = width;
LinearLayout.LayoutParams llparms = new LinearLayout.LayoutParams(width, height);
llInner.LayoutParameters = llparms;
ll.AddView(llInner);
TextView tv = new TextView(this);
tv.Id = dateindex + 100;
tv.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
tv.SetTextColor(global::Android.Graphics.Color.ParseColor("#000000"));
tv.SetBackgroundColor(Android.Graphics.Color.Yellow);
tv.SetTextSize(ComplexUnitType.Dip, 8);
tv.LayoutParameters.Height = height;
tv.LayoutParameters.Width = height;
tv.Rotation = 270;
tv.Text = timetoenter;
llInner.AddView(tv);
tv.Gravity = GravityFlags.CenterHorizontal;
CurrentTimeSlot = CurrentTimeSlot + TimeSlotAdder;