How does an android:attr style work?

I’m trying to build an Android UI via layouts. I start with the following:


And that looks good (all caps, smaller font, dividing bar underneath it). Now I want to extend the style, so I change it to the following:

  • How to detect if navigation drawer is open?
  • Cannot detect Sony Xperia in Eclipse
  • Pinch Zoom ListView Android
  • How to determine which platform the current app is running on in LibGDX?
  • Show Current Location and Nearby Places and Route between two places using Google Maps API in Android
  • JNI ERROR (app bug): accessed stale local reference 0xbc00021 (index 8 in a table of size 8)
  • <TextView

    With a style of:

    <style name="section_title" parent="@android:attr/listSeparatorTextViewStyle">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>

    And that doesn’t work (font is correct, but the divider line is gone).

    How come… that?

    Related posts:

    Deleting events from Calendar not being deleted
    How to prevent client from seeing internal private classes in Android library ?
    Android 4.3 with Genymotion uvesafb: failed to execute /sbin/v86d
    ActionBarActivity: cannot be resolved to a type
    Draw and hook guestures without stopping app underneith
    CookieSyncManager is now deprecated, what can I use instead?
  • Why the PendingIntent doesn't send back my custom Extras setup for the Intent?
  • CircleCI Android constraintLayout doesn't work
  • Android: Invalid use of SingleClientConnManager: connection still allocated
  • reorder pages in FragmentStatePagerAdapter using getItemPosition(Object object)
  • Espresso: return boolean if view exists
  • Adding kSOAP dependency to Gradle project
  • One Solution collect form web for “How does an android:attr style work?”

    When you’re using:


    you’re using the style pointed by this attribute(listSeparatorTextViewStyle). If you look in the platform themes.xml you’ll see that the style that is actually used for this attribute is Widget.TextView.ListSeparator.White. So this is the style you should extend in your custom style.

    Unfortunately that style is private and you can’t extend it, or you shouldn’t extend it(for reference, see this bug report from google). Your best option would be to copy that entire style, Widget.TextView.ListSeparator.White(Widget.TextView.ListSeparator isn’t public as well so would have to also copy that), in your custom style and use that instead of extending the style from the android platform(see this response from the link above).

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.