[英]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. 我的问题也许很愚蠢,但我是一个初学者,我在Android Studio中使用两个Activity创建了导航抽屉应用程序。 In First Activity ( MainActivity), this activity Show Title Bar but the second Activity(Parametre) does not show Title Bar.
在第一个活动(MainActivity)中,此活动显示标题栏,但第二个活动(Parametre)不显示标题栏。 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"
. 删除行
android:theme="@style/AppTheme.NoActionBar"
。 You might want to look into your Theme editor
to see what your default Activity
looks like 您可能需要查看
Theme editor
以查看默认Activity
外观
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) requestWindowFeature(Window.FEATURE_NO_TITLE)
If you are using 如果您正在使用
extends AppCompatActivity
change it to 更改为
extends Activity
in your Java code. 在您的Java代码中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.