【发布时间】:2017-12-21 19:20:18
【问题描述】:
我现在真的很沮丧,读了很多书——也许你能帮帮我。 为什么 Android Studio 仍然显示带有标题栏的“Main2Activity”?
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.martin.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Main2Activity"
android:theme="@android:style/Theme.Light.NoTitleBar"></activity>
</application>
我知道这确实是一个小问题,但我无法弄清楚......
我使用的来源:
https://developer.android.com/guide/topics/ui/look-and-feel/themes.html
Apply a theme to an activity in Android?
编辑 当前状态: enter image description here
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
正在工作,但会为每个 Activity 禁用 ActionBar!
目标:activity_main2 不应有 ActionBar。
已解决 这只是 Android Studio 的一个错误。在预览版中,它不会禁用 AppBar,但只要您在手机上播放该应用程序,它就会起作用!
【问题讨论】:
-
你的 XML 布局有工具栏吗?
-
是的,目标是我的布局将有一个工具栏。目前把它放在一个简单的例子中:我有 2 个活动。其中一个将保留“默认”栏,另一个将获得一个工具栏。因此全屏对我来说是没有选择的sry
-
我的意思是你仍然看到这个栏,因为活动布局告诉它加载一个,即使主题没有一个
-
对不起,我现在很困惑:是的,默认是我的 App 有一个 AppBar。但是在 Manifest 中为活动提供另一个主题并不会改变任何事情。我不知道为什么......
标签: android android-layout android-manifest