如何在Xamarin.Forms中创建多行文本框?
经过一些研究,我发现可以使用XAML页面中的<Editor>
标签来完成,还可以自定义字体大小和样式,但这会创建一个居中对齐的文本框。然而,我想要从左上角开始插入光标和文本。
如何在Xamarin.Forms中创建多行文本框?
经过一些研究,我发现可以使用XAML页面中的<Editor>
标签来完成,还可以自定义字体大小和样式,但这会创建一个居中对齐的文本框。然而,我想要从左上角开始插入光标和文本。
编辑器用于收集需要占据多行的文本。
例如:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TextSample.EditorPage"
Title="Editor">
<ContentPage.Content>
<StackLayout>
<Editor Text="Editor is used for collecting text that is expected to take more than one line." BackgroundColor="#2c3e50" HeightRequest="100" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
Editor
,并指定最大字符数:<Editor Keyboard="Plain" AutoSize="TextChanges" MaxLength="180" />
AutoSize="TextChanges"
选项,编辑器会在用户输入时自动调整大小以适应输入内容。默认情况下,自动调整大小是关闭的。 <StackLayout Padding="5,10">
<Editor>
<Editor.BackgroundColor>
<OnPlatform x:TypeArguments="x:Color"
iOS="#a4eaff"
Android="#2c3e50"
WinPhone="#2c3e50" />
</Editor.BackgroundColor>
</Editor>
</StackLayout>