我想在android中删除应用程序蓝条上的标题栏,我尝试在manifest.xml ( android:theme="@style/AppTheme.NoTitleBar"
)中使用一个不同的主题,但是这不起作用,那么,我如何隐藏这个标题栏以避免这种活动呢?
我的manifest.xml是:
我的styles.xml是:
发布于 2016-03-27 14:54:49
在手机左侧(布局预览),点击AppTheme文本,选择你想要的主题。我用红色高亮了一下
发布于 2016-03-27 15:13:13
转到App>Res>Values>styles xml。
在<resources>
标记之后,您拥有的第一件事可能是另一个名称为AppTheme
的<style>
标记?或者类似的东西。如果使用的是Material theme
,就会在那里声明colorPrimary, colorPrimaryDark
和accentColor
。
在此主题的</style>
标记结束后,创建一个名称相同的新主题,但将.NoActionBar
添加到名称中,如下所示:
<style name="YourThemeName.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBarOverlay">true</item>
</style>
现在转到您的Manifest.xml
中,在每个<activity>
标记中可能有一个主题属性。更改它,以便您希望没有标题栏的活动使用我们创建的新主题:
android:theme="@style/YourThemeName.NoActionBar"
您的主题应该如何看起来像
<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>
只要记住,就可以将颜色名称更改为在colors.xml中声明的颜色名称。现在在您的报表中,您的应用程序的主题应该是MyTheme
,而不使用标题栏的每个Activity
的主题应该是MyTheme.NoActionBar
发布于 2016-03-27 15:27:25
这是我的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>
对于我的活动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>
https://stackoverflow.com/questions/36253561
复制相似问题