Ryan
Ryan

Reputation: 155

Unable to show title on android actionbar

This is my android manifest

 <application
        android:allowBackup="true"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"

        >
        <activity
            android:name=".splash"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity
            android:name=".DrawingActivity"
            android:parentActivityName="com.example.kahheng.smartchat.MainActivity"/>
        <activity
            android:name=".pollActivity"
            android:parentActivityName="com.example.kahheng.smartchat.MainActivity"/>
        <activity
            android:name=".bookmarkActivity"
            android:parentActivityName="com.example.kahheng.smartchat.bookmarkActivity"
            android:label="Bookmark Page"

            />
        <activity
        android:name=".ContactListActivity"
            />
        <activity
            android:name=".MainActivity" />

    </application>

This is my style file

<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light">
        <item name="windowActionBar">false</item>

        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:actionBarStyle">@style/MyActionBarTheme</item>

    </style>

    <style name="MyActionBarTheme" parent="android:Theme.Material.Light">
        <item name="android:background">#255e7c</item>

    </style>
    <style name="ContactListTheme" parent="android:Theme.Material.Light">

    </style>
</resources>

How to make my app name appear on the android:actionBarStyle? if I apply the the actionbar theme to my activity, the whole screen will change into that colour.

I not sure what is happening.

It is okay when it was default, the word on the actionbar is gone when I apply the style for actionbar.

I have two XML file, activity_main and content_main.xml How to do manually define title for a actionbar in XML?

Upvotes: 0

Views: 118

Answers (1)

tiny sunlight
tiny sunlight

Reputation: 6251

<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light">
//this 2 line remove actionbar
 //       <item name="windowActionBar">false</item>

  //      <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:actionBarStyle">@style/MyActionBarTheme</item>

    <style name="MyActionBarTheme" parent="android:Widget.Material.Light.ActionBar">
    //<style name="MyActionBarTheme" parent="android:Theme.Material.Light">
        <item name="android:background">#255e7c</item>

    </style>
    <style name="ContactListTheme" parent="android:Theme.Material.Light">

    </style>
</resources>

Upvotes: 1

Related Questions