【发布时间】:2023-02-04 04:09:10
【问题描述】:
在 .net-Maui 中,当我在 scrollView 中添加一个 ViewElement 并且键盘出现时,键盘隐藏了 ViewElement。 如果我删除 ScrollView 它工作正常,但我无法滚动内容。
在 Xamarin 上,Android 会自动将 ViewElement 滚动到视图中,那么为什么会发生这种变化?。
我必须在毛伊岛做一些不同的事情吗?
这是代码示例。
public class TestView : ContentView
{
public TestView()
{
var layout = new AbsoluteLayout();
var scrollView = new ScrollView { Content = layout, };
Content = scrollView;
var entry = new Entry();
layout.Add(entry);
AbsoluteLayout.SetLayoutBounds(entry, new Rect(20, 600, 200, 45));
}
}
如果我这样做,它会起作用,但这对我来说不是解决方案。
public class TestView : ContentView
{
public TestView()
{
var layout = new AbsoluteLayout();
Content = layout ;
var entry = new Entry();
layout.Add(entry);
AbsoluteLayout.SetLayoutBounds(entry, new Rect(20, 600, 200, 45));
}
}
我希望 ViewElement 自动滚动到视图中。
【问题讨论】:
-
在 Xamarin 上,您有相同的布局,包括 AbsoluteLayout 和 ScrollView?如果您删除 AbsoluteLayout,它是否适用于 ScrollView?
-
是的,它在 ScrollView 中使用 AbsoluteLayout 在 Xamarin 上工作,我正在尝试将我的应用程序移植到 Maui insted of Xamarin。如果我在滚动视图中使用其他布局没有区别,我尝试了 RelativeLayout 和 StackLayout,这是同一个问题
标签: maui