5

In my manifest I used to have something like this

<activity android:name=".MyActivity"
     android:label="@string/app_name"
        name="Theme.NoTitleBar"...

and it worked great, I mean the title bar was not shown.

But now I want to customize the theme (I want to extend the default android theme) and I created this theme

<style name="Theme.NoTitleBar.new_skin" parent="android:Theme">
        <item name="text_body_read">@style/text_body_read</item>
        <item name="text_body_unread">@style/text_body_unread</item>
    </style>

then in the manifest I set name="Theme.NoTitleBar.new_skin", but the title bar is still shown.

how can I hide the title bar and still have my new custom theme ?

and one more question does adding dots '.' means extending when working with styles ?

Lukap
  • 31,523
  • 64
  • 157
  • 244

1 Answers1

2

in your mainfest you should write something like:

<activity android:name=".MyActivity"
     android:label="@string/app_name"
        name="MyTheme"...

In your styles.xml you should write something like:

<style name="MyTheme" parent="android:Theme.NoTitleBar">
        <item name="text_body_read">@style/text_body_read</item>
        <item name="text_body_unread">@style/text_body_unread</item>
 </style>

Dot (.) doesn't mean extending. It means referencing a certain element (listview, textview etc.) in your theme. For example, you would have:

<style name="MyTheme.Widget.ListView" parent="@android:style/Widget.ListView.White">
</style>

to define style of your listview.

Maggie
  • 7,823
  • 7
  • 45
  • 66
  • the problem is that I have name="MyTheme" in my manifest and parent="android:Theme.NoTitleBar" in the style but I still have the title bar visible – Lukap Oct 06 '11 at 09:42
  • try this: 1. inside your theme style add: @style/MyTheme.WindowTitleBackground 2. create a new style: – Maggie Oct 06 '11 at 10:00
  • It gives me an error, it couldn't find parent="android:WindowTitleBackground, but what is the point with the background ? I need just the title bar to be hidden – Lukap Oct 06 '11 at 10:13
  • it makes your title not visible. – Maggie Oct 06 '11 at 10:17
  • eclipse complains about parent="android:WindowTitleBackground", it says no resource found ... – Lukap Oct 06 '11 at 10:27
  • You wrote that "Dot (.) doesn't mean extending" but it actually means that in context of Themes. Please take a look here: https://developer.android.com/guide/topics/ui/look-and-feel/themes The quote is following: "You can also inherit styles (...) with a dot notation, instead of using the parent attribute." – LLL Jul 08 '22 at 13:40