简体   繁体   中英

how to display title Bar on activity

My question is maybe stupid but I'm a beginner I have create navigation drawer application in Android Studio with two Activity. In First Activity ( MainActivity), this activity Show Title Bar but the second Activity(Parametre) does not show Title Bar. Hier ist my code.

 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>

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

Delete the line android:theme="@style/AppTheme.NoActionBar" . You might want to look into your Theme editor to see what your default Activity looks like

You should either add

public classname extends AppCompatActivity 

to have a title bar or

public classname extends Activity

to remove a title bar or you can also use

requestWindowFeature(Window.FEATURE_NO_TITLE)

If you are using

extends AppCompatActivity

change it to

extends Activity

in your Java code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM