如何显示活动的标题栏

k4ymrczo  于 2021-07-09  发布在  Java
关注(0)|答案(4)|浏览(416)

我的问题可能是愚蠢的,但我是一个初学者,我已经创建了两个活动在android工作室导航抽屉应用程序。在第一个活动(mainactivity)中,此活动显示标题栏,但第二个活动(parametre)不显示标题栏。这是我的密码。

Androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pandl.fragment">

<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.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".SingleViewActivity"></activity>

    <activity android:name=".Playboard"></activity>
    <activity
        android:name=".Parametre"

        android:label="Parametre"></activity>

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

  </application>

   </manifest>

            styles.xml

                <resources>

                <!-- Base application theme. -->

                <style name="AppTheme" 
  parent="Theme.AppCompat.Light.DarkActionBar">
                    <!-- Customize your theme here. -->
                    <item name="colorPrimary">@color/colorPrimary</item>
                    <item 
   name="colorPrimaryDark">@color/colorPrimaryDark</item>
                    <item name="colorAccent">@color/colorAccent</item>
                </style>

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

                <style name="BaseTheme" parent="AppTheme">
                    <item name="windowActionBar">false</item>
                    <item name="windowNoTitle">true</item>
                </style>

                <style name="AppTheme.AppBarOverlay" 
   parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

                <style name="AppTheme.PopupOverlay" 
   parent="ThemeOverlay.AppCompat.Light" />

            </resources>
mwyxok5s

mwyxok5s1#

如果您正在使用

extends AppCompatActivity

把它改成

extends Activity

在java代码中。

oyt4ldly

oyt4ldly2#

你要么

public classname extends AppCompatActivity

有标题栏或

public classname extends Activity

要删除标题栏,也可以使用
requestwindowfeature(窗口功能\u无\u标题)

bvjveswy

bvjveswy3#

删除行 android:theme="@style/AppTheme.NoActionBar" . 你可能想看看你的 Theme editor 看看你的默认值是多少 Activity 看起来像

daupos2t

daupos2t4#

通过删除此行更改活动的样式 android:theme="@style/AppTheme.NoActionBar">

相关问题