Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Xamarin表单编辑器将控件从尖叫中推出_C#_Xamarin.forms_Xamarin.android_Editor - Fatal编程技术网

C# Xamarin表单编辑器将控件从尖叫中推出

C# Xamarin表单编辑器将控件从尖叫中推出,c#,xamarin.forms,xamarin.android,editor,C#,Xamarin.forms,Xamarin.android,Editor,我是xamarin表单的初学者,我需要创建一个包含一些标签和编辑器的页面。我想要android中的默认键盘重叠:WindowSoftInputModeAdjust.Pan。当我在编辑器中书写时,键盘打开时可以显示丰富的最大大小,它会将标签从尖叫中推出。如何禁用编辑器在发出尖叫声的同时将标签推出,但同时可以滚动其中的文本 <StackLayout> <Label Text="First"/> <Label Text="Secon

我是xamarin表单的初学者,我需要创建一个包含一些标签和编辑器的页面。我想要android中的默认键盘重叠:WindowSoftInputModeAdjust.Pan。当我在编辑器中书写时,键盘打开时可以显示丰富的最大大小,它会将标签从尖叫中推出。如何禁用编辑器在发出尖叫声的同时将标签推出,但同时可以滚动其中的文本

    <StackLayout>
        <Label Text="First"/>
        <Label Text="Second"/>
        <Label Text="Third"/>
        <Label Text="Fourth"/>
        <Label Text="Fifth"/>
        <Label Text="Sixth"/>
        <Editor HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Red" />
    </StackLayout>


您必须将编辑器放在stacklayout中

<StackLayout>
    <Label Text="First"/>
    <Label Text="Second"/>
    <Label Text="Third"/>
    <Label Text="Fourth"/>
    <Label Text="Fifth"/>
    <Label Text="Sixth"/>
    <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <Editor VerticalOptions="FillAndExpand" BackgroundColor="Red" />
    </StackLayout>
</StackLayout>

据我所知,发生这种情况的原因是因为
VerticalOptions=“FillAndExpand”

当你阅读文件时,它会说:

StartAndExpand、CenterAndExpand、EndAndExpand和FillAndExpand值用于定义对齐首选项,以及视图是否会占用更多空间(如果在父StackLayout中可用)

我建议您将其删除,然后重试

有关更多信息,请查看:

更新 您的代码应该如下所示:

<Grid> 
<Grid.RowDefinitions>
<Grid.RowDefinition Height="Auto"/>
<Grid.RowDefinition Height="*"/>
</Grid.RowDefinitions>
 <StackLayout Grid.Row="0">....<StackLayout> //all the labels here
  <Editor Grid.Row="1" VerticalOptions="FillAndExpand" .../>
 </Grid>

.... //所有的标签都在这里
编辑 我正在使用下面的代码,它就像Xamarin上的一个符咒。Forms 4.2,我还附加了一个屏幕截图供您查看它的外观

 <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackLayout Grid.Row="0">
            <Label Text="First" />
            <Label Text="Second" />
            <Label Text="Third" />
            <Label Text="Fourth" />
            <Label Text="Fifth" />
            <Label Text="Sixth" />
        </StackLayout>
        <Editor
            Grid.Row="1"
            AutoSize="Disabled"
            BackgroundColor="Red"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand" />
    </Grid>

如何禁用编辑器在发出尖叫声的同时将标签推出,但同时可以滚动其中的文本

    <StackLayout>
        <Label Text="First"/>
        <Label Text="Second"/>
        <Label Text="Third"/>
        <Label Text="Fourth"/>
        <Label Text="Fifth"/>
        <Label Text="Sixth"/>
        <Editor HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Red" />
    </StackLayout>
如果您想这样做,我建议您不能将Editor verticaloptions设置为FillAndExpand,否则它将始终将控件推出屏幕

<StackLayout>
        <Label Text="First" />
        <Label Text="Second" />
        <Label Text="Third" />
        <Label Text="Fourth" />
        <Label Text="Fifth" />
        <Label Text="Sixth" />
        <ScrollView>
            <Editor
                x:Name="editor"
                BackgroundColor="Red"
                HorizontalOptions="FillAndExpand"
                VerticalOptions="FillAndExpand" />

        </ScrollView>

    </StackLayout>

更新:


我需要编辑器获取标签下的所有可用空间,而不是一些默认高度或必要的高度thnx

您可以在App()构造函数中调用以下代码

 Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
Xamarin.Forms.Application.Current.On().UseWindowsOfInputModeAdjust(WindowsOfInputModeAdjust.Resize);
并使用Scrollview进行滚动

<StackLayout>
        <Label Text="First" />
        <Label Text="Second" />
        <Label Text="Third" />
        <Label Text="Fourth" />
        <Label Text="Fifth" />
        <Label Text="Sixth" />
        <ScrollView VerticalOptions="FillAndExpand">
            <Editor
                x:Name="editor"
                BackgroundColor="Red"
                HorizontalOptions="FillAndExpand"
                VerticalOptions="FillAndExpand" />

        </ScrollView>

    </StackLayout>

屏幕截图如下:


我试过你的答案,但问题是一样的。Stile将标签从尖叫中推出。我在Android上试过,效果很好。你在iOS上遇到过这个问题吗?我现在不可能在iOS上尝试,但我完全按照你的建议处理了。恐怕我误解了你的部分问题。要实现此功能,您需要编写一个自定义编辑器。我需要编辑器占用标签下的所有可用空间,而不是一些默认高度或必要的高度thnx。好的,在这种情况下,我只需稍微更改布局,再次更新回答,与以前一样。我记得我尝试过此apache哈基姆不,我的朋友蒂恩!你现在可以看看我的答案了!我需要编辑器占用标签下的所有可用空间,而不是一些默认高度或必要高度thnx。@psilos,请调用
Xamarin.Forms.Application.Current.On().UseWindowsOfInputModeAdjust(WindowsOfInputModeAdjust.Resize)应用内构造函数,可以解决您的问题,您尝试过了吗,请查看我的更新。