gpt4 book ai didi

android - 添加一个看起来像 native 应用程序的设置页面

转载 作者:行者123 更新时间:2023-11-29 16:34:32 24 4
gpt4 key购买 nike

我想创建看起来像 native 平台上的设置的设置页面(例如,Android 上带有 xml 的 PreferenceActivity/Fragment)。

我习惯于通过在 Android 上创建简单的首选项 xml 来设计设置页面,它可以完美地处理基本设置,但是我无法在 Xamarin.Forms 中找到类似的机制,它会在所有平台上做同样的事情(与gui 部分)。我只找到了 SettingsPlugin,它处理“从所有应用程序的共享代码创建和访问设置!”。

https://github.com/jamesmontemagno/SettingsPlugin

如果有任何关于设计设置页面的建议,我将不胜感激。

最佳答案

您可以使用 TableView ,这是一个原始的 Xamarin Forms 用户界面(没有任何插件)。如果您设置他的 Intent="Settings" ,您可以显示一个不错的配置设置列表,例如 SwitchCell、EntryCell 或 CustomCell。

显示这些元素取决于操作系统及其版本。所以它在 f.e. 上看起来和感觉上都不一样。 Android 4.4 和 Android 8 不同。

例如:

<TableView Intent="Settings">
<TableRoot>
<TableSection Title="My settings">
<EntryCell Label="Name:" Placeholder="Enter Your First Name Here"/>
<SwitchCell Text="Show my name" On="true"/>
<SwitchCell Text="Update app automatically"/>
</TableSection>
</TableRoot>
</TableView>

这将呈现像这样的东西(不完全是那样):{source of img}

关于android - 添加一个看起来像 native 应用程序的设置页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52850763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com