如何在Xamarin表单中向标签添加垂直滚动?
我有一个大文本,我想显示它。我用的是一个标签。但此标签不显示全文。我想要这个标签的垂直卷轴如何在Xamarin表单中向标签添加垂直滚动?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我有一个大文本,我想显示它。我用的是一个标签。但此标签不显示全文。我想要这个标签的垂直卷轴 Grid mainGrid = new Grid { HeightRequest = 40, BackgroundColor = Color.White, Padding = 20, RowDefinitions = { new RowDefinition { Height = new GridLength(25, GridUnitType.Sta
Grid mainGrid = new Grid
{
HeightRequest = 40,
BackgroundColor = Color.White,
Padding = 20,
RowDefinitions =
{
new RowDefinition { Height = new GridLength(25, GridUnitType.Star) },//0 Title
new RowDefinition { Height = new GridLength(5, GridUnitType.Star) },//1 Line
new RowDefinition { Height = new GridLength(50, GridUnitType.Star) },//2 This is for MessageLabel
new RowDefinition { Height = new GridLength(20, GridUnitType.Star) },//3 OK-Cancel
}
};
MessageLabel = new Label
{
FontAttributes = FontAttributes.None,
FontSize = 18,
HorizontalTextAlignment = TextAlignment.Start,
VerticalTextAlignment = TextAlignment.Center,
HorizontalOptions = LayoutOptions.StartAndExpand,
TextColor = Color.Black,
};
mainGrid.Children.Add(MessageLabel, 0, 2);
我尝试了此标签的不同垂直选项
,但没有任何效果
如果标签不支持此操作。我可以使用其他控件吗?如果要垂直滚动,必须使用滚动视图,将标签/网格包装在滚动视图中,然后才能显示所有文本
<ScrollView>
<Grid/>
</ScrollView/>
谢谢布鲁诺·卡塞罗的提示。我已经用他提供的暗示解决了这个问题
MessageLabel = new Label
{
FontAttributes = FontAttributes.None,
FontSize = 18,
HorizontalTextAlignment = TextAlignment.Start,
VerticalTextAlignment = TextAlignment.Center,
HorizontalOptions = LayoutOptions.StartAndExpand,
TextColor = Color.Black
};
ScrollView scroll = new ScrollView()
{
Orientation = ScrollOrientation.Vertical
};
scroll.Content = MessageLabel;
有什么例子吗?我是新来的,谢谢你,这真的很有帮助