我知道这个问题已被问过几百万次,但无论我使用哪种方法对我都不好。
如果我使用
android:theme="@android:style/Theme.NoTitleBar"
在清单文件中,应用程序的整个主题发生了变化。如果我把
requestWindowFeature(Window.FEATURE_NO_TITLE);
在onCreate活动中,它会在启动应用时很快显示出来。
顺便说一下,我没有选择任何主题,仅使用标准的android。
答案 0 :(得分:27)
目前还不清楚你的意思是什么"应用程序更改的整个主题"。对于API Level 11+设备,您可能应该使用@android:style/Theme.Holo.NoActionBar
。
答案 1 :(得分:17)
如果您将主题添加到应用程序,它将适用于整个应用程序。
android:theme="@android:style/Theme.NoTitleBar"
您必须将其添加到活动声明中。
<activity
android:name=".YourActivity"
android:theme="@android:style/Theme.NoTitleBar"/>
答案 2 :(得分:12)
从android studio中的应用程序中删除标题栏
用以下代码替换您的代码:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
答案 3 :(得分:10)
打开style.xml文件,创建一个新样式,如下所示。 您可以选择自己的名称并将父级设置如下
<style name="your_own_name" parent="Theme.AppCompat.Light.NoActionBar">
</style>
在AndroidManifest.xml文件中,设置您不希望该栏显示的特定活动的主题名称,并且您已完成
<activity android:theme ="@style/your_own_name" >
</activity>
答案 4 :(得分:4)
这对我有用
android:theme="@style/Theme.AppCompat.NoActionBar">
答案 5 :(得分:1)
当您在Android中创建一个新项目时,您将获得应用于您的项目的默认主题,该主题具有标题栏。但如果您想删除或应用整个应用程序的其他主题,那么您可以在应用程序级别定义如下:
<application
android:name="com.mycomp.myproj.MainApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
但如果您只想在某些特定屏幕上应用某些主题,那么您可以在活动级别定义如下:
<activity
android:name="com.mycomp.myproj.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
答案 6 :(得分:1)
对于Android 8及以上的支持。在您的应用主题文件中使用此选项。我修改了res / styles.xml中的默认值:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">@color/white</item>
</style>
答案 7 :(得分:0)
AndroidManifest内部
<activity
android:name=".activity.HomeMenu"
android:screenOrientation="nosensor"
android:theme="@android:style/Theme.Light.NoTitleBar">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
并确保您的课程延伸至活动
答案 8 :(得分:0)
如果您在styles.xml中创建了自定义主题,则可以执行以下操作:
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Override the android colour scheme etc. -->
<item name="android:colorPrimary">@color/color_primary</item>
</style>
删除操作栏和标题添加到styles.xml:
<style name="AppTheme.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
然后,在您的AndroidManifest.xml中,您可以使用带有或不带操作栏的自定义主题
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"> <---- With action bar
<activity
android:theme="@style/AppTheme.NoActionBar"> <---- No action bar
<intent-filter>
etc...