Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.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
从Android Studio中删除应用程序的栏标题_Android_Android Layout - Fatal编程技术网

从Android Studio中删除应用程序的栏标题

从Android Studio中删除应用程序的栏标题,android,android-layout,Android,Android Layout,我想删除android studio中应用程序的标题栏,我尝试在manifest.xml中使用不同的主题 (android:theme=“@style/AppTheme.NoTitleBar”)但这不起作用,那么,我该如何隐藏此活动的标题栏 我的manifest.xml如下所示: my styles.xml是这样的: 在手机上方的左侧(布局预览)有AppTheme文本,单击该文本并选择所需的主题。我用红色突出显示了它转到应用程序>资源>价值观>样式xml 在标记之后的第一件事是另一个名为Ap

我想删除android studio中应用程序的标题栏,我尝试在manifest.xml中使用不同的主题 (
android:theme=“@style/AppTheme.NoTitleBar”
)但这不起作用,那么,我该如何隐藏此活动的标题栏

我的manifest.xml如下所示:

my styles.xml是这样的:


在手机上方的左侧(布局预览)有AppTheme文本,单击该文本并选择所需的主题。我用红色突出显示了它

转到应用程序>资源>价值观>样式xml

标记之后的第一件事是另一个名为
AppTheme
标记?或者类似的东西。如果您使用的是
材质主题
,则会在此处声明
colorPrimary、colorPrimaryDark
accentColor

在该主题的
标记结束后,创建一个同名的新主题,但在名称中添加
.NoActionBar
,如下所示:

    <style name="YourThemeName.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBarOverlay">true</item>
    </style>
你的主题应该是什么样的

 <style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/teal</item>
    <item name="colorPrimaryDark">@color/tealDark</item>
    <item name="colorAccent">@color/purple700</item>
    <item name="android:navigationBarColor" tools:targetApi="21">@color/teal</item>
</style>

<style name="MyTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBarOverlay">true</item>
</style>

@颜色/青色
@彩色/茶色
@颜色/紫色700
@颜色/青色
假的
真的
真的
只需记住将颜色名称更改为您在colors.xml中声明的颜色名称即可。现在,在您的清单中,应用程序的主题应该是
myteme
,而不使用标题栏的每个
活动的主题应该是
myteme.NoActionBar
这是my Stiles.xml

<resources>>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

<style name="AppTheme.NoTitleBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBarOverlay">true</item>
</style>
>
假的
真的
真的
@android:彩色/透明
假的
真的
真的

对于我的activity manifest.xml,我执行以下操作:

    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Main2Activity"
        android:label="@string/title_activity_main2"
        android:theme="@style/AppTheme.NoActionBar" />



</application>

我假设您的应用程序使用的是最新版本的Android。如果没有,请提及正在使用的Android版本。以下是删除活动顶部蓝色条的方法:-

  • 转到活动xml文件并从xml中删除以下代码:-

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />
    

    
    

  • 现在,如果您切换到设计模式,那么您将能够在顶部没有蓝色条的情况下看到屏幕


    希望这能有所帮助。

    在预览中,您可以选择要使用的主题,在预览中,您可以选择无标题栏主题。我可以在哪里找到此选项?谢谢你的回复!!好的,我找到了,没有选择标题栏。但是,请将缺少的样式返回给我。因此,我访问了my styles.xml,发现:“…”我尝试为NoTitleBar添加我的样式,在我的清单中进行了更改之后,Desive show me Android的显示却没有任何更改。协调布局。在清单中,在每个标记(而不是应用程序标记)中,确保使用此特定主题,而不仅仅是AppTheme。我在我的答案中添加了更多信息,确保它都是这样的。如果你的答案不起作用,试着复制粘贴我的代码并按照我的指示设置主题,它仍然不起作用吗?当添加关于你的问题的更多信息时,不要发布答案,除非它是答案,只需编辑你原来的帖子。我不知道您是否复制粘贴错误,但很明显,您的起始标记有一个双
    >
    文件应该以开头和结尾,顺便说一句,您甚至没有正确的主题设置。这就是为什么我给你的代码应该是什么样子。定义colorPrimary等,并扩展其中一个AppCompat主题。看看我的答案,在“你的主题应该是什么样子”之后复制样式。很抱歉,我从几天开始看android语言,所以如果我添加到styles.xml,请告诉我没有找到文件,我不理解此代码。抱歉!如果您还没有支持库,请查看此视频以了解如何下载支持库:这是一个关于主题和样式的视频,8:15他们开始讨论应用程序主题。现在我看到了此视频,希望这对我有所帮助!!非常感谢:)我找不到这个,在哪个xml中?你能将活动xml粘贴到你试图删除蓝色条的屏幕上吗?我在问题中添加了它!您可以尝试从活动xml的LinearLayout标记中删除行“app:layout”吗?linear:layout必须具有android:layout,如果我将其删除,将返回一个错误,然后丢失
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />