Singaram Manickam
Singaram Manickam

Reputation: 45

How to fix the App name on the top of the Activity

In my design page of My Android Studio Project, the App Name is shown in the top of the activity(Action Bar). But, when I debug the App, the App name is not Shown on the top of the Activity. I want the App name should be shown. How to fix it.

My styles.xml is...

<!-- 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="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

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

Upvotes: 1

Views: 101

Answers (2)

skydroid
skydroid

Reputation: 733

I think you was asking about ActionBar

from docs

A primary toolbar within the activity that may display the activity title, application-level navigation affordances, and other interactive items.

Beginning with Android 3.0 (API level 11), the action bar appears at the top of an activity's window when the activity uses the system's Holo theme (or one of its descendant themes), which is the default. You may otherwise add the action bar by calling requestFeature(FEATURE_ACTION_BAR) or by declaring it in a custom theme with the windowActionBar property.

If you want to change it from java code, write in

Activity.java

ActionBar ab = getActionBar();
ab.setTitle("My new title");

Or, in the Androidmanifest.xml file:

<activity 
       android:name=".MyActivity" 
       android:icon="@drawable/my_icon" 
       android:label="My new title" />

hope my answer help you..

Upvotes: 0

Dipali Shah
Dipali Shah

Reputation: 3798

Set your App theme to Theme.AppCompat.Light.DarkActionBar in style.xml

For e.g.

 <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>

Upvotes: 1

Related Questions