如何在Xamarin.Forms中删除(Android)应用标题栏? [英] How to remove (Android) app title bar in Xamarin.Forms?

查看:289
本文介绍了如何在Xamarin.Forms中删除(Android)应用标题栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否有可能在Xamarin.Forms中删除应用程序的标题栏?我正在研究Xamarin.Forms可移植项目.我尝试了很多解决方案,但均无济于事,甚至无法启动该应用程序.

Is there any chance that I can remove the title bar of the app in Xamarin.Forms? I am working on a Xamarin.Forms Portable project. I tried a lot of solutions, but neither worked, I couldn't even start the app.

首次尝试,我尝试将其添加到我的AndroidManifest.xml中,但没有成功:

First attempt I tried adding this to my AndroidManifest.xml, didn't work:

android:theme="@android:style/Theme.NoTitleBar"

第二次尝试,我尝试在资源/值"中创建一个styles.xml,即:

Second attempt I tried creating a styles.xml in Resources/values, which was:

<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
  <style name="Theme.Default" parent="@android:style/Theme"></style>
  <style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>
  <style name="Theme.FullScreen" parent="@android:style/Theme.NoTitleBar.Fullscreen"></style>
</resources>

然后将其添加到我的AndroidManifest.xml中(也不起作用)

And then I added this to my AndroidManifest.xml (didn't work either)

android:theme="@style/Theme.NoTitle"

第三次尝试,我尝试将其添加到MainActivity.cs的OnCreate方法中(无效).

Third attempt I tried adding this to my OnCreate method in MainActivity.cs (didn't work).

RequestWindowFeature(WindowFeatures.NoTitle);

有人可以帮我吗?

推荐答案

如果要删除初始页上的标题栏,最快,最简单的方法是转到XAML中的contentpage标题以获取相关信息.页面并输入

If you want to remove the title bar on the initial page, the quickest and easiest way to do it is to go to to the contentpage heading in your XAML for the page and type

NavigationPage.HasNavigationBar ="False"

所以XAML想要这样的东西

so the XAML would like something like this

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="YourClass.YourPage"
             NavigationPage.HasNavigationBar="False">

这篇关于如何在Xamarin.Forms中删除(Android)应用标题栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆