获取TextView滚动
问题描述:
我有一个TextView在GridLayout中,并设置为获取最大可用高度。这样可行。获取TextView滚动
但是,如果用户将新行按下到TextView的底部等等 - TextView光标离开屏幕的底部而不是滚动TextView。
我怎样才能让TextView滚动。
答
iOS
TextVie
如果您在其中设置大文本,w应默认为可滚动。 但是,对于Android
,您可以使用ScrollView
并将StackLayout
用于其中的主容器。对于进一步的帮助,你可以查看下面的附件中的例子:
主page.xml
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
<GridLayout columns="*" rows="auto,*">
<GridLayout row="0" col="0" columns="auto,*" rows="auto">
<Label text="header" row="0" col="0" />
</GridLayout>
<GridLayout row="1" col="0" columns="auto,*" rows="auto">
<Label text="Note" row="0" col="0" />
<ScrollView orientation="vertical" row="1" col="0" height="300" width="300" backgroundColor="green">
<StackLayout orientation="vertical" class="scroll-menu" backgroundColor="red">
<TextView text="" hint="Enter text..." />
</StackLayout>
</ScrollView>
</GridLayout>
</GridLayout>
</Page>
+0
谢谢 - 这工作!它也可以在没有在ScrollView中显式设置高度和宽度的情况下工作 - 但是对于GridLayout,您必须将行设置为* - 这是有道理的。 – dashman
你可以使用滚动型 - https://docs.nativescript.org/cookbook/ui/scroll-view并添加它内部的TextView,但是如果你能给我们示例代码,问题可以在本地复制,那么我们将能够为你的案例提供更好的解决方案。 –
这里是xml文件。 '。没有滚动。 –
dashman
是iOS还是Android? –