首先,这个帖子与那个帖子有关:Xamarin Forms Android Error inflating class MaterialCalendarGridView
在我发布任何代码之前: Xamarin表单的飞出配置是正确的!如果我在飞出页面中设置了IsPresented = true;,就会正确地显示“飞出”菜单,唯一的问题是,在Android上,顶部工具栏和汉堡包菜单图标完全丢失了。
以下是我的MainActivity.cs的定义
[Activity(ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.Portrait, LaunchMode = LaunchMode.SingleTop, MainLauncher = true, Theme = "@style/MyTheme")]
[IntentFilter(new[] { Intent.ActionView},
DataScheme = "https",
DataHost = "myapp.com",
AutoVerify = true,
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable})]
[IntentFilter(new[] { Intent.ActionView },
DataScheme = "http",
DataHost = "myapp.com",
AutoVerify = true,
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable })]
public class MainActivity : FormsAppCompatActivity, Android.Gms.Tasks.IOnSuccessListener
{
....这是我的style.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MyTheme" parent="Theme.MaterialComponents.Light">
<item name="android:colorPrimary">#ec1a23</item>
<item name="android:colorPrimaryDark">#dd2c00</item>
<item name="android:colorAccent">#ff3d00</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.Splash" parent="Theme.MaterialComponents.Light">
<item name="android:windowBackground">@drawable/splashscreen</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>正如相关文章中提到的解决方案一样,我无法创建一个toolbar.xml文件,因为我的应用程序在启动时会崩溃。关于AppCompat和Flyout文档,根本没有必要。
我真的不知道这里有什么问题。
发布于 2022-07-07 21:21:41
我自己刚刚发现了这个问题,我的解决办法是有一个定制的渲染器:
[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationRenderer))]这最初是为了修复Remove icon/logo from action bar on android而添加的,由于不再需要它,所以我可以简单地删除自定义呈现器,并按它应该显示的方式显示工具栏。
https://stackoverflow.com/questions/70398732
复制相似问题