簡體   English   中英

如何在活動中顯示標題欄

[英]how to display title Bar on activity

我的問題也許很愚蠢,但我是一個初學者,我在Android Studio中使用兩個Activity創建了導航抽屜應用程序。 在第一個活動(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>

通過刪除以下行來更改活動的樣式android:theme="@style/AppTheme.NoActionBar">

刪除行android:theme="@style/AppTheme.NoActionBar" 您可能需要查看Theme editor以查看默認Activity外觀

您應該添加

public classname extends AppCompatActivity 

有一個標題欄或

public classname extends Activity

刪除標題欄,或者您也可以使用

requestWindowFeature(Window.FEATURE_NO_TITLE)

如果您正在使用

extends AppCompatActivity

更改為

extends Activity

在您的Java代碼中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM