【发布时间】:2018-05-21 11:33:30
【问题描述】:
我使用的是最新版本的 Xamarin Forms。我有一个内容页面。内容页面有一个网格,该网格具有一个滚动视图,该滚动视图具有一个包含一些图像和条目输入以及一些按钮的堆栈布局。当我触摸 Entry 以输入文本时,键盘会覆盖按钮,因此我无法按下按钮。这是不可滚动的,我不知道为什么。任何人都可以帮助我吗?
这是我的 XAML 代码:
<?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="Spirocco.LoginPage">
<Grid>
<ScrollView Orientation="Both" x:Name="scrollView">
<ScrollView.Content>
<StackLayout BackgroundColor="#302138">
<Image Source="login_logo" Margin="0,0,0,0"></Image>
<StackLayout BackgroundColor="White" Margin="20,0,20,30">
<Label Text="ÜDVÖZÖLJÜK!" FontSize="30" FontFamily="Comic Sans MS" Margin="0,15,0,0" TextColor="#302138" HorizontalTextAlignment="Center"></Label>
<Entry Text="{Binding Email}" Placeholder="E-mail" Margin="40,0,40,0" Keyboard="Email"/>
<Entry Text="{Binding Password}" Placeholder="Jelszó" IsPassword="True" Margin="40,0,40,0"/>
<Button Text="BEJELENTKEZÉS" Clicked="Login" TextColor="White" BackgroundColor="#302138" Margin="40,10,40,0"/>
<Button Text="REGISZTRÁCIÓ" Clicked="Register" TextColor="White" BackgroundColor="#302138" Margin="40,0,40,25"/>
</StackLayout>
</StackLayout>
</ScrollView.Content>
</ScrollView>
</Grid>
【问题讨论】:
-
你想要什么是可滚动的?现在,网格中的所有内容都是您要滚动的内容。里面的元素可以相互重叠而不滚动,因为只有整组元素是。
-
我希望所有页面都可以滚动。当我尝试输入密码时,我无法触摸登录按钮,因为键盘覆盖了它。我想向下滚动所有内容并能够触摸登录按钮。对不起,我的英语不太好。
-
我认为你只需要将
<Grid>...</Grid>替换为<ContentPage.Content>...</ContentPage.Content>。无论视口大小如何,网格都可以尽可能大。但是,当 direct 子项是 ScrollView 时,ContentPage 确实知道要做什么。我无法对此进行测试,因此我不会将其发布为答案。
标签: c# xamarin scrollview