6

I just tried to post a question containing the following text:

I'm building a music app, which has an ongoing notification. I meet the text color problem of notifications:

 1. On Galaxy S with Android 2.3.3, the notification background is black, and also the texts are. That makes Galaxy S users hard to read the texts.
 2. On Motorola Droid with Android 2.2.2, the notification background is white, and so the texts are. That also makes text hard to read.

My current code is: 

### Layout XML ###
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="vertical">

        <TextView android:id="@+id/notifbar_trackname"
            style="@style/NotificationTitle"
            android:focusable="true" android:singleLine="true"
            android:layout_gravity="left" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView android:id="@+id/notifbar_artist"
            style="@style/NotificationText"
            android:layout_gravity="left" android:scrollHorizontally="true"
            android:ellipsize="end" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView android:id="@+id/notifbar_queue"
            style="@style/NotificationText"
            android:layout_gravity="left" android:scrollHorizontally="true"
            android:ellipsize="end" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

### styles.xml in values/ ###
    <style name="NotificationText">
        <item name="android:textColor">?android:attr/textColorPrimary</item>
    </style>
    <style name="NotificationTitle">
        <item name="android:textColor">?android:attr/textColorPrimary</item>
        <item name="android:textStyle">bold</item>
    </style>

### styles.xml in values/v9/ ###
    <style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" />
    <style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />

Does anyone know what's wrong in my code? Thank you!

When I try to confirm, the system says:

Oops! Your edit couldn't be submitted because:

Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.

I totally have no idea what the system is complaining about. I have all code indented by 4 spaces.

Can anyone help?

3
  • 2
    Your code appearing as code (fixed-width font, gray background, syntax highlighting) in the preview pane (below the editor) should be a good sign you've got it right...
    – Shog9 Mod
    Commented Nov 28, 2011 at 3:18
  • Irrelevant to your problem, but you don't need the last ### for the headings - the #s in front will do
    – Yi Jiang
    Commented Nov 28, 2011 at 4:06
  • @Yi Jiang: Yes, on Stack Overflow. But on GitHub it is required. Commented Dec 20, 2019 at 0:13

2 Answers 2

17

Try inserting another line break between each heading and the start of its code snippet, so

### Layout XML ###
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="vertical">

becomes

### Layout XML ###

    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="vertical">

and so on.

9

Leave a blank line after each of the headings (the ###...### lines). Without it, the parser interprets those as part of the following code blocks.

While you're at it, I would suggest not making those headings at all. They'll be sufficiently distinguished from the code blocks (which have a grey background) that there's no need for them to also appear in bold.

1
  • 1
    Thank you very much, you and the answer above solved the problem. Commented Nov 28, 2011 at 4:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .