How does an android:attr style work?

后端 未结 1 1612
一整个雨季
一整个雨季 2020-12-09 21:02

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



        
1条回答
  •  囚心锁ツ
    2020-12-09 21:08

    When you're using:

    style="?android:attr/listSeparatorTextViewStyle"
    

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

    0 讨论(0)
提交回复
热议问题